Failed Registration reported as Success
-
I am setting up a membership site for a client and they want to do some validation on member registration.
To achieve this, I setup some php code and tested the WordPress registration which works correctly.
Installing the membership plugin and testing the /register page correctly rejects a registration that is not wanted, but reports to the user that the registration was successful. Checking the user list, no member is added, so the fault is in handling the error comming from the verification code.
The hooks and code used are simply test versions currently, but are as follows:
/* Code identified in wp_insert_user() function which is the only function to actually add a new user to the database. Even the REST API functions and Multi-User Sites ultimately call this function. / $pre_user_login = apply_filters( ‘pre_user_login’, $sanitized_user_login ); $user_login = trim( $pre_user_login ); /additional checkes and filters*/
$illegal_logins = (array) apply_filters( ‘illegal_user_logins’, array() );
if ( in_array( strtolower( $user_login ), array_map( ‘strtolower’, $illegal_logins ), true ) ) {
return new WP_Error( ‘invalid_username’, __( ‘Sorry, that username is not allowed.’ ) );
}/* Code to add to filter/validate a username before it is added to the database. */
define(“DW_LOGIN_REGISTRATION_CHECK_FAILED”, “invaliduser”);function DW_pre_user_filter($sanitizes_user_login){
// make sure the user login only has digits, for testing purposes.
$length = strlen($sanitizes_user_login);
for ($count = 0; $count < $length; $count++){ if ($sanitizes_user_login[$count] < ‘0’ || $sanitizes_user_login[$count] > ‘9’ )
return DW_LOGIN_REGISTRATION_CHECK_FAILED;
}
return $sanitizes_user_login;
}
Add_filter(‘pre_user_login’, ‘DW_pre_user_filter’);function DW_illegal_user_logins($existing_array_list){return ($existing_array_list[] = DW_LOGIN_REGISTRATION_CHECK_FAILED);}
Add_filter(‘illegal_user_logins’, ‘DW_illegal_user_logins’);The page I need help with: [log in to see the link]
The topic ‘Failed Registration reported as Success’ is closed to new replies.