• Actually this turned out to be a lot easier than I thought it would be, but since I could find NO documentation on this hook anywhere, figured I’d add something here.

    In my case, there is a post type from another plugin that I simply do not want to display as it only confuses the end user…

    Accomplishing this cleanly was rather easy using 2 action hooks. Code sample follows:

    We’ll call the target post_type “foo”

    add_action('registered_post_type', 'my_registered_post_type_handler', 10, 2);
    function my_registered_post_type_handler($post_type, $args) {
      do_action("my_registered_{$post_type}_post_type", $post_type, $args);
    }
    
    add_action('my_registered_foo_post_type', 'my_registered_foo_post_type_handler', 10, 2);
    function my_registered_foo_post_type_handler($post_type, $args) {
      remove_action(current_filter(), __FUNCTION__, 10, 2);  // only run once
      // change your args here
      $args['show_ui'] = false;
      // re-register
      register_post_type($post_type, $args); // will call this hook again if it exists, so we removed it above.
    }

    And we are done.

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Modifying post type – using the registered_post_type hook’ is closed to new replies.