Add Custom validation to the field
-
Hello Team,
I have used this plugin and now I want to add custom validation on my field for the registration field.
I have sued the code which provided on the the site reference.
Please refer this link: https://docs.ultimatemember.com/article/94-apply-custom-validation-to-a-field
I used this code :
add_action(‘um_submit_form_errors_hook_’,’um_custom_validate_username’, 999, 1);
function um_custom_validate_username( $args ) {
global $ultimatemember;if ( isset( $args[‘user_login’] ) && strstr( $args[‘user_login’], ‘admin’ ) ) {
$ultimatemember->form->add_error( ‘user_login’, ‘Your username must not contain the word admin.’ );
}
}But it fires the error this:
“Uncaught Error: Call to a member function add_error() ”
So, How can I used this can you please explicit me in brif. And please give me the solution that how can I add the custom validation on my form field.
Thanks,
Riddhi Mehta
- The topic ‘Add Custom validation to the field’ is closed to new replies.