Renaming existing WP User Roles
If you are the only person who is running your website, you have probably never had to think about WordPress user roles. However, if you ever need to give access to other people access to your WordPress web site, WordPress user roles are essential for controlling what actions the various users at your site are permitted to take.
By smartly applying the WordPress user roles, you ensure that no one has more power than they need. And this helps make your site more secure and streamline your workflow. In the below code will see how to rename the existing wordpress user roles.
function wps_change_role_name() {
global $wp_roles;
if ( ! isset( $wp_roles ) )
$wp_roles = new WP_Roles();
$wp_roles->roles[‘subscriber’][‘name’] =’Member’;
$wp_roles->role_names[‘subscriber’] = ‘Member’;
$wp_roles->roles[‘lp_teacher’][‘name’] =’Trainer’;
$wp_roles->role_names[‘lp_teacher’] = ‘Trainer’;
}
add_action(‘init’, ‘wps_change_role_name’);
global $wp_roles;
if ( ! isset( $wp_roles ) )
$wp_roles = new WP_Roles();
$wp_roles->roles[‘subscriber’][‘name’] =’Member’;
$wp_roles->role_names[‘subscriber’] = ‘Member’;
$wp_roles->roles[‘lp_teacher’][‘name’] =’Trainer’;
$wp_roles->role_names[‘lp_teacher’] = ‘Trainer’;
}
add_action(‘init’, ‘wps_change_role_name’);
Post a Comment