Which files do I have to edit to get a grip on $_POST data sent by the registration form? I want to explode $_POST['email'] and build an username from that. I simply want to allow people to register only with their e-mail and password. Could you please help me with it?

  • you are using custom registration form or what?, you can easily create username from email but you have to keep in mind that multiple users can have same email with different domain, like [email protected] and [email protected], so in both case you'll be getting xyz, and other user will not get registered. what function you are using to register user, you need to describe the registration flow
    – Kumar
    Commented Mar 21, 2014 at 12:56
  • I will be exploding that e-mail with '@', then the result of that operation will be exploded with '.'. This way I will get "usernamedomain" as a username. I simply don't know which hook to use, or where $_POST data is being sent for me to intercept it. I need to modify $_POST values between the form being submitted and the validation. Someone fills in the form->clicks submit->$_POST data is modified (email as username)->$_POST data is validated. If it's possible to change those $_POST values during validation it would be also okay. Is it possible to do it this way?
    – NakedCat
    Commented Mar 21, 2014 at 13:09
  • you are using default registration form or custom registration form?
    – Kumar
    Commented Mar 21, 2014 at 13:21
  • Custom (wp-members), which sends data to the same page it is located in. I would be happy though if you could tell me the way to do it with a default registration form, then I can adapt it to that plugin form.
    – NakedCat
    Commented Mar 21, 2014 at 13:24
  • default form does not have a filter to provide custom username, although there is a sort of hack, using 'init' or 'wp_loaded' action that's why I asked you if you are using a custom form, in case of custom form as you'll be handling the registration you can easily specify the username and email to wp_create_user(), function
    – Kumar
    Commented Mar 21, 2014 at 13:36

1 Answer 1


As far as i know there is no hook or filter to provide a custom User name for default registration process, however if you really want to modify it, you can alter the $_POST data.

here is the sample code:

add_action('wp_loaded', 'wpse_138736_filter_username');
function wpse_138736_filter_username(){
  //your code to extract username from email
  $_POST['user_login'] = 'test';

It kicks in before validation, and this way you'll be able to provide custom username.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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