Prevent reset password specific user role

I have user role “b2b_account”. I want to prevent user who have role b2b_account to reset their password.

Here my code

add_filter( ‘allow_password_reset’, ‘filter_function_name_2698’, 10, 2 );
function filter_function_name_2698( $allow, $ID ){

$users = get_users(array(
‘role’ => ‘b2b_account’,
));
foreach($users as $user){
if($user->ID){

return false;

}
}
}

I use filter allow_password_reset, but it prevent all user.
Thank you for your help.

Read more here:: Prevent reset password specific user role

Leave a Reply

Your email address will not be published. Required fields are marked *