4

How do I increase Author Role permissions to be able to add Categories?

Other solutions welcome. We just need guest authors to be able to add categories while ensuring there is not already a existing appropriate category.

2 Answers 2

4

The easiest way is to use a plugin like Capability Manager or User Role Editor

6

Should work from inside your functions.php

function add_manage_cat_to_author_role() 
{
    if ( ! current_user_can( 'author' ) )
        return;

    // here you should check if the role already has_cap already and if so, abort/return;

    if ( current_user_can( 'author' ) ) 
    {
        $GLOBALS['wp_roles']->add_cap( 'author','manage_categories' );
    }
}
add_action( 'admin_init', 'add_manage_cat_to_author_role', 10, 0 );
3
  • how would you check if the role has_cap already? Thanks for any pointers
    – Osu
    Commented Mar 30, 2011 at 18:48
  • There should be a has_cap function. I'm not really sure on how this a) can be called - do you need to access the $GLOBALS['wp_roles'] object first or is it a simple global function & b) which arguments/parameters it takes. Best would be to quickly make a cross wp-core file search (using eg. notepad++) and take a look on how it's defined. I'm pretty sure you can also access and modify the $GLOBALS['wp_roles'] object, but i wouldn't recommend doing that, because it could lead to unexpected behavior if it's needed prior to your modification.
    – kaiser
    Commented Mar 30, 2011 at 19:08
  • 1
    Testing this, for me it works with global $current_user; /**/ $current_user->has_cap('cap'); /**/ $current_user->add_cap('cap');
    – brasofilo
    Commented Mar 20, 2013 at 19:44

Your Answer

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

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