• Resolved vrdpe

    (@vrdpe)


    Hi,

    I have a registration form that is only available to people that have been given a particular code can access.

    If they enter the correct code then the rest of the form fields become visible and they can complete registration.

    If they enter the incorrect code the site shows a WP critical error. When it really needs to show a form input error saying something like “That code was incorrect, please contact T2N.” With contact being a link to the relevant contact form.

    Thank you in advance for any help,
    Vee

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

    (@champsupertramp)

    Hi @vrdpe

    You can use the following code snippet to add custom error on form submission.

    add_action( 'um_submit_form_register', 'um_my_custom_validation', 10, 1 );
    function um_my_custom_validation( $args ){  
    
        if( ! isset( $args['submitted']['my_field_meta_key'] ) ) {
         UM()->form()->add_error("my_field_meta_key", "That code was incorrect, please contact T2N.");
        }
    }
    

    Regards,

Viewing 1 replies (of 1 total)
  • The topic ‘How to add custom error message if field validaiton is not met.’ is closed to new replies.