I am using ultimate member plugin in my (Wordpress)website for user registration. I have activated admin approval and also with it I am using User Verification plugin which authenticates the user email. So whenever a user register he is verified both with the user email and admin. But for some specific users having domains like (@example1.com) I want auto approval (I.e IT gets auto approved by admin but requires user authentication).
I have tried the code below but it works just opposite what i want. It takes admin approval and is auto approved for user verification.
add_action('um_user_register', 'action_um_user_register', 2, 2);
function action_um_user_register($user_id, $args){
$auto_approve_domains = array(
'example1.com',
);
$user = get_user_by('id', $user_id);
$user_email = $user->user_email;
$domain = substr(strrchr($user_email, "@") , 1);
if (in_array($domain, $auto_approve_domains ))
{
um_fetch_user($user_id);
UM()->user()->approve();
}
}
I expect that admin side the user should be auto approved for specific domains(like @example1.com) and requires user authentication