@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.
Thanks for letting us know. I’m marking this as resolved now.