0
votes

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

1

1 Answers

0
votes

Do the above changes as mentioned like making admin approval and using user verification to make two way authentication and do the following thing as well:

Go to the code section and go to wp-content > plugin > ultimate-member > includes > core > um-actions-register.php and under the third add action function add the following code :

 function um_post_registration_pending_hook( $user_id, $args ) {
  um_fetch_user( $user_id );
    $auto_approve_domains = array(
    'example.in');
    $user = get_user_by('id', $user_id);
    $domain = substr(strrchr($user->data->user_email, "@") , 1);
    if(in_array($domain, $auto_approve_domains )){
            um_fetch_user($user_id);
    UM()->user()->approve();
    }else{
    UM()->user()->pending();
    }
}

Now by doing this the it auto approves the email coming from example.in