Created
August 30, 2016 19:39
-
-
Save wpcrmsystem/3b83a60cb6847ee59a1d4b9155a6d402 to your computer and use it in GitHub Desktop.
WP-CRM System Custom Roles
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
/* 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