Note: This content is more than one year old. It may not contain the most up to date information.
Out of the box, Restrict Content Pro requires members to enter a username when registering. This makes sense because RCP uses the built-in WordPress user database, and the username is a requirement. However, we often see people wanting to use the email address as the username, and they want to know how to remove the username field from the registration form. This is pretty easy to do with just a few lines of code. Let’s take a look.
Removing the username field
First, we need to remove the username field from the form. To do that, copy the registration template into your child theme folder, and remove the username field. The RCP documentation covers this step here.
However, removing the field from the form doesn’t remove the code that makes the field a requirement, and it doesn’t make the username the email address. To do that, continue on.
Removing the username field requirement and using the email address
When someone submits the registration form, RCP checks that the username field is completed. If it’s missing or empty, the registration will not successfully complete. To remove this requirement, and to use the email address instead, you need this small code snippet.
If you’re not familiar with how to add a code snippet to your site, you can install Pluginception, use it to create a new custom plugin, paste in the code, and activate your new plugin.
That’s all there is to it! With these few simple steps, you can remove the username field from your registration form and use the email address for the username instead.
5 thoughts on “How to use an email address for the username in Restrict Content Pro”
Thank you for this nice explanation. I had wanted to do just this (in the hope that decreasing fields on the signup form would decrease complexity) but I was intimidated by the thought of editing the template files or the core files. But this tutorial was easy to follow and I managed to get it working on my own website. Thanks!
I just hid the registration field in some custom CSS, and didn’t mess with the template files. That made it easier.
Hey Jim, glad to hear it!
I’ve tried implementing this but when a user resets their password, the reset link sent to them refers to their username and when they click the link, they get an error that the “reset link seems invalid”.
What does the link look like?