Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support Aswin Giri

    (@aswingiri)

    Hello @xxaimsxx

    Please try following code snippets:

    add_action( 'um_user_register', function( $user_id, $args ){
        
        $user = get_user_by( 'ID', $user_id );
        $email = $user->user_emaill;
    
        list($email_user, $domain) = explode('@', $email);
    
        if ($domain == 'gmail.com') {
            add_user_meta( $user_id, 'company', 'Google');
        }
    
    }, 10, 2 );

    This code snippet is just an example, please feel free to customize it base on your requirement.

    Thread Starter xxaimsxx

    (@xxaimsxx)

    Thank you, I will try that now. Sorry it took so long to get back to you. Been very busy with a sick baby.

    Thread Starter xxaimsxx

    (@xxaimsxx)

    @aswingiri Is the um_user_register hook only work after user registers and completes confirmation email?

    Plugin Support Aswin Giri

    (@aswingiri)

    Hello @xxaimsxx

    um_user_register hook is used to create a new user in the database but depending priority set for the hook, it can run before or after user registration.

    You can also try um_registration_complete hook as it only runs after the user registration process.

    add_action( 'um_registration_complete', 'my_registration_complete', 10, 2 );
    function my_registration_complete( $user_id, $args ) {
    // your codes go here
    }
    Thread Starter xxaimsxx

    (@xxaimsxx)

    @aswingiri Thank you.

    So if I wanted the ACF relationship field to be populated once they register but before they complete registration (like confirm email, etc), would I use the default priority of 10,2?

    Sorry if I’m asking a stupid question, I’m quite new to using hooks/functions.

    Plugin Support Aswin Giri

    (@aswingiri)

    @xxaimsxx If the priority of any hook is 1, it runs before any actions with a priority of more than 1.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Automatically assign user company based on email domain’ is closed to new replies.