Remove The Username Field And Allow Email Only Registration

Note: This is part of the developer docs and is considered custom code.
Unfortunately, we cannot provide support for custom code at this time as we do not have the additional resources that would be necessary to provide support for custom code.

If you need assistance with this, please reach out to our list of consultants for further assistance:
https://codeable.io/developers/restrict-content-pro/

By default, the Restrict Content Pro registration form has two separate fields:

  • Username
  • Email

This tutorial will show you how to remove the username field and allow registration with email only. Members will be able to login with their email address directly instead of remembering a separate username.

Remove The Username Form Field

Add this custom CSS snippet to Appearance > Customize > Additional CSS to hide the username field:

#rcp_user_login_wrap {
    display: none;
}

Set The Email As The Username

Just removing the field isn't enough, because RCP is expecting a username to be entered and will throw an error if it's not filled out. To combat this, we need to remove the "Username is empty" error message and assign the email as the username. To do that, add this code to your child theme's functions.php file or to a custom plugin:

<?php
/**
 * This will remove the username requirement on the registration form
 * and use the email address as the username.
 */
function jp_rcp_user_registration_data( $user ) {
	rcp_errors()->remove( 'username_empty' );
	$user['login'] = $user['email'];
	return $user;
}

add_filter( 'rcp_user_registration_data', 'jp_rcp_user_registration_data' );

Please note: All of these examples serve as a guideline and are here for your convenience. We do not provide support for troubleshooting or modifying these and we do not provide support for any custom development. If you need help with any of these examples, consider hiring a developer.

Powered by Zendesk