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.
return true
if you don't find the user. (And possibly abort immediately if $allow is false?) However there must be better ways of doing this, e.g. look up the user ID we have and see what roles it has rather than fetching all users in the role?