Require First Name & Last Name
-
Hi. On the registration page, how do I require users to fill in their first and last name? I have checked the ‘Require First & Last Name’ under Settings>General>Account but still users were able to register by providing only their username, email and password. I was expecting some sort of error warning when they forgot to add their first and last name but no, this didn’t happen at all.
As a step further, I also added a PHP code which supposedly requires users to fill in their first and last name when registering. Unfortunately, this didn’t help either./** * Require first and last name on user registration. */ function require_first_last_name_on_registration( $errors, $sanitized_user_login, $user_email ) { if ( empty( $_POST['first_name'] ) ) { $errors->add( 'first_name_required', __( '<strong>ERROR</strong>: First name is required.', 'mydomain' ) ); } if ( empty( $_POST['last_name'] ) ) { $errors->add( 'last_name_required', __( '<strong>ERROR</strong>: Last name is required.', 'mydomain' ) ); } return $errors; } add_filter( 'registration_errors', 'require_first_last_name_on_registration', 10, 3 );
Can someone help me out please?
Thanks.
- The topic ‘Require First Name & Last Name’ is closed to new replies.