Adding custom post status to visibility in publish meta box

The question:

We have two different custom user roles that have custom capabilities. What I’m trying to do is to add two custom visibility statuses that are visible from the publish meta box on the edit page.

enter image description here

I’ve got the post statues registered but I saw on the codex wiki that there is no easy way to add it to the list but I figured I would turn here to see if anyone has done something similar?

The Solutions:

Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.

Method 1

I also don’t see a way to edit that form in that location, though there is a hook called post_submitbox_misc_actions near the bottom.

I strongly suggest that use that post_submitbox_misc_actions hook or add your own brand new meta_box to the page. There are potentially severe consequences to altering the default meta_boxes, especially that one.

However… if you must…

Remove that box:

function remove_taxonomies_submit_box() {
    remove_meta_box( 'submitdiv', 'book', 'side' );
}
add_action( 'add_meta_boxes_book' , 'remove_taxonomies_submit_box', 100 );

And add back a box of your own construction (Generic Example):

function add_altered_submit_box() {
  add_meta_box(
    'submitdiv', // id, used as the html id att
    __( 'Generic Title' ), // meta box title
    'generic_cb', // callback function, spits out the content
    'book', // post type or page. 
    'side', // context, where on the screen
    'high' // priority, where should this go in the context
  );
}
add_action( 'add_meta_boxes_book' , 'add_altered_submit_box', 101 );

The callback, of course, will be a near duplicate of the original submit box callback. The post type in those examples is ‘book’ that will need to be changed to match your post type.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Comment