1

Is it possible to edit existing registered post statuses?

I am using the Edit Flow plugin to create custom statuses, however, the plugin does not offer the option to set whether the statuses are 'public' or not. I went in to the code and was able to insert that in, but obviously that will get overwritten with any updates. Essentially, I am looking for a complimentary function to add_post_type_support() for post statuses.

So something like

add_action('init', 'my_custom_init');
function my_custom_init() {

      add_post_status_support( 'custom_status', array('public'=>true) );

}

1 Answer 1

2

You can alter a post status after init by changing the global variable $wp_post_statusses:

function alt_post_status() {
    global $wp_post_statuses;

    $wp_post_statuses['custom_status']->public = true;
}

add_action( 'init', 'alt_post_status' );

register_post_status() (line 922) does the same thing:

...

global $wp_post_statuses;

if (!is_array($wp_post_statuses))
    $wp_post_statuses = array();

// Args prefixed with an underscore are reserved for internal use.
$defaults = array(
    'label' => false,
    'label_count' => false,
    'exclude_from_search' => null,
    '_builtin' => false,
    'public' => null,
    'internal' => null,
    'protected' => null,
    'private' => null,
    'publicly_queryable' => null,
    'show_in_admin_status_list' => null,
    'show_in_admin_all_list' => null,
);
$args = wp_parse_args($args, $defaults);
$args = (object) $args;

...

$wp_post_statuses[$post_status] = $args;

...
1
  • Works perfectly, the first part anyway, didn't test the second since the first worked ha
    – Kyle
    Dec 21, 2012 at 14:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.