I want to use an email address instead of username to register and login my members. I've got the login part working using some of the code in this answer. Works fine but as expected wordpress still wants a username on the register page (custom, not the default).

This line of code registers the user: $user_signup = wp_insert_user( $user_data );, and when registering I get the following error:

Cannot create a user with an empty login name.

I'm guessing this can be solved by removing the appropriate filter, but I'm new to wordpress. What's the code to remove the username requirement?


This is a required field (http://codex.wordpress.org/Function_Reference/wp_create_user) and I think that more than one function in the core of Wordpress relies on that. So I would not recommend to code around it or alter any other WP core files as the next update could render all these changes back to the default values.

| improve this answer | |
  • I'm doing this in my functions.php file so it won't be affected by future updates. And there are plugins that do the exact same thing. However you make a good point. I might just insert the email into the username field to account for plugins that rely on that, somewhat of a hack but it'll work. I'll wait and see if something else comes up. – justanotherhobbyist Jul 17 '14 at 13:27
  • Very much true, while being in your current functions.php you are very safe from any updates. Sorry for overlooking that detail. I am not sure if the username field allows for the required special characters (@ .), but if that works it would be a nice compromise. – sogathon Jul 17 '14 at 13:33
  • 1
    Yeah, just tried it and it works fine. I think I'll might just go for that. Can't believe I didn't think of that earlier. Thanks anyway, have some rep. :) – justanotherhobbyist Jul 17 '14 at 13:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.