Hi @israfel78
You can try adding a text field with a meta key ‘pass_code’ to your register form for users to enter the code and then add the following code snippet to your site:
add_action("um_submit_form_register","um_102821_passcode");
function um_102821_passcode( $post_form ){
if( isset( $post_form['pass_code'] ) && ! empty( $post_form['pass_code'] ) ){
if( $post_form['pass_code'] !== "mypasscode" ){
UM()->form()->add_error('pass_code', __( 'Invalid pass code', 'ultimate-member' ) );
}
}
if( empty( $post_form['pass_code'] ) ){
UM()->form()->add_error('pass_code', __( 'Enter a pass code', 'ultimate-member' ) );
}
}
The above code will validate the pass_code
field. If they enter the pass code mypasscode
incorrectly the error will show Invalid pass code
in the form.
Regards,
Hi Camp Camba,
thank you so much for your answer.
The only thing that is not clear to me is where to put the code.
Do I have to insert it in a UM parcular file?
in case you could tell me which one?
Beste regards
Enrico
Hi @israfel78
Sorry for the late response.
You can add the code to your theme/child-theme’s functions.php file or use the Code Snippet plugin to run the code.
If you have issues, please create a topic on the forum instead:
https://wordpress.org/support/plugin/ultimate-member/
Regards,