Skip to content

Instantly share code, notes, and snippets.

@wp-user-manager
Created December 16, 2023 19:10
Show Gist options
  • Save wp-user-manager/f10850f8e439ddbbc265d4f5b21d994c to your computer and use it in GitHub Desktop.
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
<?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 );
@wp-user-manager
Copy link
Author

Save this file to your /wp-content/mu-plugins/ directory (you might need to create the mu-plugins directory).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment