Skip to content

Instantly share code, notes, and snippets.

@wpcrmsystem
Created August 30, 2016 19:39
Show Gist options
  • Save wpcrmsystem/3b83a60cb6847ee59a1d4b9155a6d402 to your computer and use it in GitHub Desktop.
Save wpcrmsystem/3b83a60cb6847ee59a1d4b9155a6d402 to your computer and use it in GitHub Desktop.
WP-CRM System Custom Roles
/* How are displayed in the dropdown menu on WP-CRM System Dashboard
-------------------------------------------------------------------*/
add_filter( 'wpcrm_system_user_role_options', 'wpcrm_system_select_user_roles', 10 );
//roles should be listed with a capability as the key and the name of the role as the value
//all roles with the capability listed in the key will have access to WP-CRM System
function wpcrm_system_select_user_roles( $array ){
$array = array(
'manage_options' => __('Administrator', 'wp-crm-system'),
'edit_pages' => __('Editor', 'wp-crm-system'),
'publish_posts' => __('Author', 'wp-crm-system'),
'edit_posts' => __('Contributor', 'wp-crm-system'),
'read' => __('Subscriber', 'wp-crm-system')
);
return $array;
}
/* How to modify roles that are displayed in the dropdown menu on WP-CRM System Dashboard
----------------------------------------------------------------------------------------*/
// Remove the original user role options
add_action( 'wpcrm_system_user_role_options', 'change_access_levels', 1 );
function change_access_levels() {
remove_filter( 'wpcrm_system_user_role_options', 'wpcrm_system_select_user_roles', 10 );
}
// Add your custom options
add_filter('wpcrm_system_user_role_options', 'my_new_role_options_menu', 1 );
function my_new_role_options_menu( $array ){
$array = array(
'manage_options' => __('Administrator', 'wp-crm-system'),
'edit_pages' => __('Editor', 'wp-crm-system'),
'delete_forums' => __('Keymaster', 'wp-crm-system')
);
return $array;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment