Hi Mariette,
1. Here is the code that you can insert at the end of your theme’s functions.php file to disable password change for a particular role:
add_filter('allow_password_reset', 'disable_password');
function disable_password()
{
if(is_admin()) {
$userdata = wp_get_current_user();
$user = new WP_User($userdata->ID);
if(!empty($user->roles) && is_array($user->roles) && $user->roles[0] == 'administrator')
return false;
}
return true;
}
In this case it is Administrator but you can change it.
2. I’m not sure if this is possible because when the user is not logged in, WordPress doesn’t know the role this user has.
Cheers
Thread Starter
Mariette
(@mariette-jackson)
Thank you very much for the code, that’s great. Haha – hadn’t thought of that for number 2! No worries.