Custom message status is not displayed

I am creating a catalog theme for my client, and I like to add an expiration function in messages, changing the status of a message from a publication before the expired date.

To achieve this, I am trying to register a new message status using the following code:

add_action('init', 'registerStatus', 0); function registerStatus() { $args = array( 'label' => _x('Expired', 'Status General Name', 'z' ), 'label_count' => _n_noop('Expired (%s)', 'Expired (%s)', 'z'), 'public' => true, 'show_in_admin_all_list' => true, 'show_in_admin_status_list' => true, 'exclude_from_search' => true ); register_post_status('expired', $args); } 

The problem is that I cannot see the registered status of the message either in WordPress posts or in my custom post post post types.

Am I doing something wrong?

+6
source share
4 answers

Custom message status features are still under development (as they have been over the past four years!), See https://core.trac.wordpress.org/ticket/12706 and comments https://wordpress.stackexchange.com/ q / 67655/25765 . More useful information here: https://wordpress.stackexchange.com/search?q=register_post_status .

Personally, I would categorically refuse to implement custom message statuses, but if it is really necessary, you can see how the Plug-in processes the Modify stream process it.

+5
source

Thanks to Ryan Bayne, I was able to add a custom message status to the admin panel on the message editing page. There is no wordpress filter. His solution with jQuery is perfect. Here's the code if anyone is looking for a solution:

 add_action( 'post_submitbox_misc_actions', 'my_post_submitbox_misc_actions' ); function my_post_submitbox_misc_actions(){ global $post; //only when editing a post if( $post->post_type == 'post' ){ // custom post status: approved $complete = ''; $label = ''; if( $post->post_status == 'approved' ){ $complete = 'selected=\"selected\"'; $label = '<span id=\"post-status-display\"> Approved</span>'; } echo '<script>'. 'jQuery(document).ready(function($){'. '$("select#post_status").append('. '"<option value=\"approved\" '.$complete.'>'. 'Approved'. '</option>"'. ');'. '$(".misc-pub-section label").append("'.$label.'");'. '});'. '</script>'; } } 
+7
source

This feature is still awaiting further development.

ATTENTION: This function does NOT add the registered message status to the admin panel. This functionality is awaiting further development. Please refer to Trac Ticket # 12706 . To add this parameter, consider the link to the post_submitbox_misc_actions action.

+2
source

Now is November 2014 and still issues user statuses. I think the source code is published. Here is a video showing the problem that you will encounter when implementing custom message status. There may be workarounds, that is, connecting to a message request and executing a user request, but I have not started researching.

A scenario of messages that are not displayed throughout the table when a custom status is applied, however, messages can be found in the table view for each custom status. Click here to view a short clip.

This screencast was accepted when I was working on my new WTG Tasks Manager plugin. I will leave my project in the plugin as it is, and I hope it helps to encourage improvements in this area of ​​WordPress.

For the correct answer ... my user status is displayed on the "Edit Message" screen for my custom message type so that it is possible. If you want to look at my plugins, registering custom message types and statuses, go to the "posttypes / tasks.php" directory and play with a working example. Here is the official plugins page ...

https://wordpress.org/plugins/wtg-tasks-manager/

+1
source

Source: https://habr.com/ru/post/959077/


All Articles