Skip to content

Instantly share code, notes, and snippets.

@erikccoder
Created May 10, 2013 04:50
Show Gist options
  • Save erikccoder/5552446 to your computer and use it in GitHub Desktop.
Save erikccoder/5552446 to your computer and use it in GitHub Desktop.
wordpress add custom role and capability
// add custom role & capability
add_action('admin_init', 'add_custom_role');
function add_custom_role()
{
$marketing = add_role('marketing',
'Marketing',
array(
'read' => true,
'manage_links',
'manage_categories',
'moderate_comments',
'view-stats')
);
if (null !== $marketing) {
$role = get_role('administrator');
$role->add_cap('view-stats');
}
// remove capability
$role = get_role( 'contributor' );
$role->remove_cap( 'read' );
$myRole = add_role('myRole',
'My Role',
array(
'read' => true
// ,'view-stats'
)
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment