Title: Documentation
Last modified: August 21, 2016

---

# Documentation

 *  [antoinicolas](https://wordpress.org/support/users/antoinicolas/)
 * (@antoinicolas)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/documentation-28/)
 * This plugin seems interesting, though lacking documentation.
    Could you provide
   some examples just like Codex does on how to use the hooks your plugin adds to
   WordPress ? Best regards, Antoine
 * [http://wordpress.org/plugins/custom-status/](http://wordpress.org/plugins/custom-status/)

Viewing 1 replies (of 1 total)

 *  [lucdecri](https://wordpress.org/support/users/lucdecri/)
 * (@lucdecri)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/documentation-28/#post-4115228)
 * Hi
 * this is a simple snippet to use this plugin
 *     ```
       // create a new post status
       add_action('init','myplugin_init');
       function myplugin_init() {
         register_post_status( 'closed',
                                array(
       				'label' => 'Closed',
       				'public' => false,
       			) );
       }
   
       // hook to "available_status" to add new status in the select in "publish box"
       //add_filter('available_statuses','myplugin_liststatus');  // for a bug this don't work properly. use next hook, instead
       add_filter('myposttype_available_statuses','myplugin_liststatus'); // you can use this in you want edit select only for myposttype
       function myplugin_liststatus($statuses) {
           $statuses['closed'] = 'Closed';
           return $statuses;
       }
   
       // hook to "publish_action" to edit label in publish button when you want go in your new status
       add_filter('publish_action','myplugin_publish_action');
       //add_filter('myposttype_publish_action','myplugin_publish_action');
       function myplugin_publish_action($action) {
       global $post;
           switch ($post->post_status) {
           /*
             this is normal work-flow
               case 'draft'     :
               case 'auto-draft':
                                  if (current_user_can('publish')) return array('label'=>'Publish', 'action'=>'publish');
                                  else                             return array('label'=>'Pending', 'action'=>'publish');
               break;
               case 'pending' :
               					return array('label'=>'Publish', 'action'=>'publish');
               break;
           */
               case 'publish'   : if (current_user_can('publish_myposttype')) return array('label'=>'Close now', 'action'=>'publish');
                                  else                                  return array('label'=>'Update', 'action'=>'publish');
               break;
               case 'closed'   :
               					return array('label'=>'Re-open', 'action'=>'publish');
               break;
   
           }
   
       }
       // You can use "save_action" hook to edit label in "save" button
       add_filter('save_action','myplugin_save_action');
       //add_filter('myposttype_save_action','myplugin_save_action');
       function myplugin_save_action($action) {
       global $post;
           if ($post->post_status=='closed') return array('label'=>'Save as closed', 'action'=>'save');
        }
   
       // REMEMBER : set the correct status in publish_post action because anoter filter/plugin can reset your status in "publish"
       add_action('publish_myposttype','myplugin_workflow');
       function myplugin_workflow() {
       global $post;
   
           $new_status = $post->post_status;
           if ($_POST['post_status']=='closed') $post->post_status = 'closed';
           if ($new_status!='publish') wp_update_post($post);
   
       }
       ```
   
 * of course you can use only the hooks that you need
 * if you need more explanation post another comment here,
 * goodnight

Viewing 1 replies (of 1 total)

The topic ‘Documentation’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/custom-status.svg)
 * [Custom Status](https://wordpress.org/plugins/custom-status/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/custom-status/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/custom-status/)
 * [Active Topics](https://wordpress.org/support/plugin/custom-status/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/custom-status/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/custom-status/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [lucdecri](https://wordpress.org/support/users/lucdecri/)
 * Last activity: [12 years, 8 months ago](https://wordpress.org/support/topic/documentation-28/#post-4115228)
 * Status: not resolved