Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question

2 Answers 2

up vote 2 down vote accepted

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

share|improve this answer

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 );
share|improve this answer
    
how would you check if the role has_cap already? Thanks for any pointers –  Osu Mar 30 '11 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 Mar 30 '11 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 Mar 20 '13 at 19:44
    
@brasofilo Thanks for confirming –  kaiser Mar 21 '13 at 1:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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