• Resolved cobraeagle

    (@cobraeagle)


    Hi,

    Is it possible to generate the email (in the regestration form) from the first name and laste name? Then autofill the @mail.com

    Thank you
    Vr
    Michael

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @cobraeagle

    You can use this filter hook to modify the email address on Registration:
    um_add_user_frontend_submitted

    e.g.

    add_filter("um_add_user_frontend_submitted", function( $args ){
    
        $args['user_email'] = $args['first_name'].".".$args['last_name']."@mail.com";
    
        if ( email_exists( $args['user_email'] ) ) {
            UM()->form()->add_error( 'first_name', __( 'Email already linked to another account', 'ultimate-member' ) );
        }
    
        return $args;
    });

    You will have issues when there are users with the same first and last name – they won’t be registered so you will have to modify the code snippet above to add a condition and display an error in the form.

    Regards,

    Thread Starter cobraeagle

    (@cobraeagle)

    Hi @champsupertramp,

    Thank you for the support. I am gonna try to add this filter hook

    Gr,
    Michael

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @cobraeagle

    Thanks for letting us know.

    Regards,

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Generate email’ is closed to new replies.