Skip to content

Instantly share code, notes, and snippets.

@lewismcarey
Last active August 29, 2015 13:57
Show Gist options
  • Save lewismcarey/9511329 to your computer and use it in GitHub Desktop.
Save lewismcarey/9511329 to your computer and use it in GitHub Desktop.
Add a new role to WORDPRESS who can manage users
/**
* Add a default client user role
*
* @author - lewismcarey
*
*/
function create_site_manager_user_role() {
$result = add_role(
'site_manager',
'Site Manager',
array(
'activate_plugins' => false,
'delete_others_pages' => true,
'delete_others_posts' => true,
'delete_pages' => true,
'delete_plugins' => false,
'delete_posts' => true,
'delete_private_pages' => true,
'delete_private_posts' => true,
'delete_published_pages'=> true,
'delete_published_posts'=> true,
'edit_dashboard' => false,
'edit_files' => true,
'edit_others_pages' => true,
'edit_others_posts' => true,
'edit_pages' => true,
'edit_posts' => true,
'edit_private_pages' => true,
'edit_private_posts' => true,
'edit_published_pages' => true,
'edit_published_posts' => true,
'edit_theme_options' => false,
'export' => false,
'import' => false,
'list_users' => true,
'manage_categories' => true,
'manage_links' => true,
'manage_options' => true,
'moderate_comments' => true,
'promote_users' => true,
'publish_pages' => true,
'publish_posts' => true,
'read_private_pages' => true,
'read_private_posts' => true,
'read' => true,
'remove_users' => true,
'switch_themes' => false,
'upload_files' => true,
'create_product' => true,
'update_core' => false,
'update_plugins' => false,
'update_themes' => false,
'install_plugins' => false,
'install_themes' => false,
'delete_themes' => false,
'edit_plugins' => false,
'edit_themes' => false,
'edit_users' => true,
'create_users' => true,
'delete_users' => true,
'unfiltered_html' => true
)
);
}
add_action( 'admin_init', 'create_site_manager_user_role' );
# WORDPRESS Add custom role
This function adds an additional role called site manager.
This is primarily to allow a client admin rights ( including managing users )
It enables you to then hide administrator admin menu items from site managers.
## Usage
* add below code to functions.php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment