• Resolved rinh

    (@rinh)


    Hi
    I wonder if it would be possible to make a field on registration form where the user has to put in the correct numbers?

    As an example I’d like to create a form field where the user has to put in 1234, and it’ll only be valid if they put in 1234.

    I think this page is on the track to what I’d like https://docs.ultimatemember.com/article/94-apply-custom-validation-to-a-field but I don’t know PHP to be able to change those examples.

    Thank you in advance.

Viewing 6 replies - 1 through 6 (of 6 total)
  • @rinh

    Have you seen this example of solution for your issue?

    https://docs.ultimatemember.com/article/68-stop-registration-if-customercode-field-does-not-equal-abcde

    customer_code is your meta-key field in the Registration Form
    Replace ABCDE with your value 1234

    Thread Starter rinh

    (@rinh)

    I hadn’t seen that one, thank you!

    From a quick look that seems to do exactly what I’m looking for. I’ll give it a try as soon as I can.

    Thread Starter rinh

    (@rinh)

    This worked great, thank you.

    Is there a way to edit the message ‘An error has occured’ when putting in the wrong passcode, to something like ‘Please put in the correcct passcode’?

    Also in the validate option for the field I put it to Unique Metakey value. I’m not sure I was supposed to do that or if there should be something else.

    Thank you in advance.

    @rinh

    You can try this code snippet:

    add_action( 'um_submit_form_errors_hook', 'check_customer_code', 100, 1 );
    function check_customer_code( $args ){
    
    	if ( isset( $args['customer_code'] ) && $args['customer_code'] != '1234' ) {
            UM()->form()->add_error( 'customer_code', 'Please put in the correcct passcode' );
        } 
    }

    Don’t use Unique Metakey value.
    Setting Numeric value only might guide those without the right number code.

    Thread Starter rinh

    (@rinh)

    Wonderful, worked out really well.

    Thank you again for all the help.

    Plugin Support Ultimate Member Support

    (@ultimatemembersupport)

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

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Passcode field on registration’ is closed to new replies.