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.
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 );
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.
global $current_user; /**/ $current_user->has_cap('cap'); /**/ $current_user->add_cap('cap');
Commented
Mar 20, 2013 at 19:44