Created
May 10, 2013 04:50
-
-
Save erikccoder/5552446 to your computer and use it in GitHub Desktop.
wordpress add custom role and capability
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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