1

I'd like to prevent the "Featured" category from appearing for certain user roles. To be specific, I want only the admins and editors to be able to see and thus select or unselect that category. Everybody else can see the whole tree but the Featured cat.

Which hooks and WP API do I need to tap into in writing the necessary plug in?

2

Based on the first Answer from Mike Schinkel. For testing purposes in a default installation, the category is "Uncategorized".

add_filter( 'list_terms_exclusions', 'wpse_59652_list_terms_exclusions', 10, 2 );

function wpse_59652_list_terms_exclusions( $exclusions, $args ) 
{
    global $current_screen;

    if( 'post' != $current_screen->post_type )
        return $exclusions;

    if( !current_user_can('delete_others_pages') )
        return $exclusions;

    return $exclusions . " AND ( t.name <> 'Uncategorized' )"; 
}
  • Thanks brasofilo. I know Mike from the hackers list. This should do the trick. On a higher level, what's a good place to start learning, what hooks are available on certain actions? Is there a way (or perhaps a plug in ), to output which hookable functions have run at any given time? For example, we update a post and and the next page displays all the functions that have run to make that happen along with a list of all hookable function names? See what I mean? – Average Joe Jul 29 '12 at 10:10
  • Well, that's almost a new Q ;) . . . See: --Debug Objects --Debug Bar --Debug Bar Extender --Where Can I Find a List of WordPress Hooks? --WordPress System Diagrams – brasofilo Jul 29 '12 at 10:35
0

You could check out this plugin. It does exactly the same thing -> Restrict Categories

  • Yes, but this is an overkill, in my case, there is no need to go thru the set up of options. I can hardcode the cat id that I want to exclude. What I was trying to achieve was to be able to write such a plug in using as little code as possible. Thank you for your reply Joshua. – Average Joe Jul 26 '12 at 13:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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