Hi @gteyespy
Unfortunately, this requires customization on your end.
Have you set up a custom post type or a new database table for the promo code? Or is the promo code static or just a few numbers of Promo code?
Regards,
Hey there!
This thread has been inactive for a while so we’re going to go ahead and mark it Resolved.
Please feel free to re-open this thread by changing the Topic Status to ‘Not Resolved’ if any other questions come up and we’d be happy to help. 🙂
Regards,
Sorry for the late reply as I was on Holiday
I think the best route would be a new table in the DB
but i guess my question really is how do connect the form field (text) registration form as required and the db table to check if refferer code is valid.
Then i can write a JS that says If user referral code equals A then load JS A. else equals B Load JS B . . etc.
Hi @gteyespy
You can create a new field with custom validation. Please see this doc explaining how to add a custom validation in PHP:
https://docs.ultimatemember.com/article/94-apply-custom-validation-to-a-field
Regards,
Hey there!
This thread has been inactive for a while so we’re going to go ahead and mark it Resolved. ..Please feel free to re-open this thread by changing the Topic Status to ‘Not Resolved’ if any other questions come up and we’d be happy to help. 🙂
Regards,
i saw this and this is where i need help as i’m a PHP newb.
where do I put in the parameter for the list i want to accept as the invite code.
i.e dog, cat, bird, fish
i’m sorry for the stupid qestion. i’m just new at this.
/**
* Validate field Invitation Code
* @param string $key
* @param attay $array
* @param array $args
*/
function um_custom_validate_invite( $key, $array, $args ) {
if ( isset( $args[$key] ) && !preg_match(‘dog, cat, bird, fish’, $args[$key]) ) {
UM()->form()->add_error( $key, __( ‘Please enter valid Invitation code.’, ‘ultimate-member’ ) );
}
}
add_action( ‘um_custom_field_validation_invite’, ‘um_custom_validate_invite’, 30, 3 );`
Hi @gteyespy
Sorry for the late response.
You can try this code snippet:
function um_custom_validate_invite( $key, $array, $args ) {
if ( isset( $args[$key] ) && ! in_array( $args[$key],['dog','cat','bird','fish']) ) {
UM()->form()->add_error( $key, __( ‘Please enter valid Invitation code.’, ‘ultimate-member’ ) );
}
}
add_action( ‘um_custom_field_validation_invite’, ‘um_custom_validate_invite’, 30, 3 );
The above code will check if the Invite code doesn’t match the input. If the input is not from the list(‘dog’,’cat’,’bird’,’fish’), it will throw Please enter valid Invitation code.
Feel free to re-open this thread if there’s any question that may come up.
Regards,