• Resolved rafi45678

    (@rafi45678)


    So someone helped me already with this code for the email field validation but I also need to change the form validation on the username if that user name already exists how can I change this code to work for it

    add_action( 'um_add_error_on_form_submit_validation', function( $array, $key, $args ){
        
        if( 'user_email' == $key ){
            if( get_user_by( 'email', $args[$key] )){
                UM()->form()->add_error( $key, __( 'That Email address is already registered', 'ultimate-member' ) );
            }
        }
    
    },1,3 );

    thanks

    • This topic was modified 1 week, 4 days ago by rafi45678.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Aswin Giri

    (@aswingiri)

    Hello @rafi45678

    Please try following code snippets:

    add_action( 'um_add_error_on_form_submit_validation', function( $array, $key, $args ){
        
        if( 'user_login' == $key ){
            if( get_user_by( 'login', $args[$key] )){
                UM()->form()->add_error( $key, __( 'That Username is already registered', 'ultimate-member' ) );
            }
        }
    
    },1,3 );
    Thread Starter rafi45678

    (@rafi45678)

    Thank you so much!!

    Plugin Support Ultimate Member Support

    (@ultimatemembersupport)

    Thanks for letting us know. I’m marking this as resolved now.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.