Created
December 16, 2023 19:10
-
-
Save wp-user-manager/f10850f8e439ddbbc265d4f5b21d994c to your computer and use it in GitHub Desktop.
WP User Manager - Stop registrations when the first and last name is the same
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'submit_wpum_form_validate_fields', function ( $check, $fields, $values, $form_name ) { | |
if ( ! isset( $values['register']['user_firstname'] ) || empty( $values['register']['user_firstname'] ) ) { | |
return $check; | |
} | |
if ( ! isset( $values['register']['user_lastname'] ) || empty( $values['register']['user_lastname'] ) ) { | |
return $check; | |
} | |
if ( $values['register']['user_firstname'] === $values['register']['user_lastname'] ) { | |
return new WP_Error( 'validation-error', __( 'First and last name cannot be the same', 'wp-user-manager' ) ); | |
} | |
return $check; | |
}, 100, 4 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Save this file to your /wp-content/mu-plugins/ directory (you might need to create the mu-plugins directory).