• Resolved vvbetai

    (@vvbetai)


    I am inserting following code in “code snippets” and putting confirm_email in Customer Action field in ultimate member registration form. The code does not work for me. Can someone please help debug this?

    function um_custom_validate_useremail( $args ) {
    global $ultimatemember;
    if ( isset($args[‘user_email’]) !== ($args[‘confirm_email’])) {
    UM()->form()->add_error ( ‘user_email’, ‘Please verify both emails match’ );
    }
    }
    add_action( ‘um_custom_field_validation_confirm_email’, ‘um_custom_validate_useremail’, 10, 3 );

Viewing 8 replies - 1 through 8 (of 8 total)
  • Hi @vvbetai,

    Try this:

    function um_custom_validate_username( $key, $array, $args ) {
    global $regcode;
    $regcode = $args[$key];
    if ( isset( $regcode ) && $regcode !== ($args[‘user_email’])) {
    UM()->form()->add_error( $key, __( ‘Please verify both emails match’, ‘ultimate-member’ ) );
    }
    }

    add_action( ‘um_custom_field_validation_confirm_email’, ‘um_custom_validate_username’, 30, 3 );

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @vvbetai

    In the Confirm Email field settings, did you select “Custom” in the “Validate” options ?

    Regards,

    Thread Starter vvbetai

    (@vvbetai)

    Thanks @cyrfan

    I tried your code, it accepted the form without any error, even when two emails IDs were not matching.

    Thread Starter vvbetai

    (@vvbetai)

    @champsupertramp

    Yup, I selected ‘custom validation’ in the validate field and entered confirm_email in ‘custom action’ field.

    My code is working great so you made a mistake i think (look images please):

    https://zupimages.net/up/20/22/jd06.png
    https://zupimages.net/up/20/22/my03.png

    Thread Starter vvbetai

    (@vvbetai)

    I noticed, my email meta key was not user_email. After fixing it, the form always gives error, even if email ID matches. There seems to be something simple that I am missing. Here is the content of registration form:

    Title : Email address
    Meta Key : user_email
    Validate : Unique-Email

    Title : Confirm email
    Meta Key : confirm_email
    Validate : Custom Validation
    Custom Action : confirm_email

    Code inserted in Code Snippet:

    function um_custom_validate_useremail( $args ) {
    global $ultimatemember;
    if ( isset($args[‘user_email’]) !== ($args[‘confirm_email’])) {
    UM()->form()->add_error ( ‘confirm_email’, ‘Please verify both emails match’ );
    }
    }
    add_action( ‘um_custom_field_validation_confirm_email’, ‘um_custom_validate_useremail’, 10, 3 );

    Thread Starter vvbetai

    (@vvbetai)

    @cyrfan

    Your code and um doc gave some clue and finally following code worked for me. Thank you.

    function um_custom_validate_useremail( $key, $array, $args ) {
    if ( isset( $args[$key] ) && $args[$key] !== ($args[‘user_email’])) {
    UM()->form()->add_error( $key, __( ‘Please verify both emails matches.’, ‘ultimate-member’ ) );
    }
    }
    add_action( ‘um_custom_field_validation_confirm_email’, ‘um_custom_validate_useremail’, 30, 3 );

    Thread Starter vvbetai

    (@vvbetai)

    Thank you everyone, the example given in Ultimate Member doc for developer in How to is very useful.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘confirm email in registration form’ is closed to new replies.