Recently, I’m working on a pretty intresting project. It will be an e-healthcare site, or something like that.
And I’ve chosen BuddyPress as the foundation for that.

The fact, that we are not willing to create an online community, but we need, the fancy stuff like, user management, flexible profile data handling, extendability, and so forth.

But, as the site is forming in my mind, some methods will change during the developement, but one major thing won’t. And I’m very certain about that. This is the login method, and I want to use email based login, and forget about the login/username based method.

First of all I installed WP-Email-Login plugin to be able to login with not just username, but with email as well.
After that I realized, that I need rather an AJAX Login widget, so I installed AJAX Login Widget++ and rewritten it, to fulfill the needs of the project.

But, there came, the BuddyPress part. Which is the main story today.
As you know, on the register page, it asks for a login name.
As I realized I can’t just skip that, or remove username errors during the process. So I’ve choosen to generate an md5 hash as a login name, from the e-mail address, on the back of them. So they won’t see it, they won’t need it.

This “solution” only works, if you does not plan social functions, such as blogs, on “mentions” handling, where the login name shows up and looks really ugly. Really.

So, here how I did it, I added these to my own theme’s (yeah, a buddypress child theme) functions.php:

add_action( 'bp_core_validate_user_signup', 'my_theme_validate_user_signup' );

function my_theme_validate_user_signup($result)

  if(!empty($result['user_email']) && empty($result['errors']->errors['user_email']))
    $result['user_name'] = md5($result['user_email']);
    $_POST['signup_username'] = $result['user_name'];

  return $result;

If you don’t understand PHP, let me explain.
First, we add action, which runs, before the user adding process.
If the e-mail is correct, and right, this function removes the warnings according to the login. Then it removes login, and replace it, with the md5 hash of the email. After that, we fake as it was added by the user.

This last thing is essential, thus there’s a checking whether the login/username was really posted or not later in registration process, outside the BuddyPress user creation mechanism. That’s why we have to fake this :)

On the other hand, you have to wipe out the input form and stuff from the registration/register.php of your BuddyPress theme. So to be clear, you have to remove these lines:

<label for="signup_username"><?php _e( 'Username', 'buddypress' ) ?> <?php _e( '(required)', 'buddypress' ) ?></label>
<?php do_action( 'bp_signup_username_errors' ) ?>
<input type="text" name="signup_username" id="signup_username" value="<?php bp_signup_username_value() ?>" />

I know, this whole thing is a dirty solution.
I just can’t find any easier, and better one.
If you know one, please let me know ;)

16 comments so far

Add Your Comment
  1. I deeply like the plugin: AJAX Login Widget++, but it only support wordpress to 2.7.1, and in wordpress 3.0, it can’t support to registration, it will mention : unknown registration response, do you find the way to solve it? your reply is highly appreciation. Marcus, my email: marcusyong08@gmail.com

  2. I removed the registration part from the AJAX Login Widget++, thus, you can’t use BuddyPress custom forms, and stuff, this way.

  3. thanks, and I found the way as same as yours in last night. and give another register door for new comer.

  4. Pretty crazy, but so smart!

    Do you know if there is a plugin to do this so far?

    Thx for this!

  5. I think, you don’t need a plugin for this, just put these lines intho your theme’s functions.php and that’s it.

  6. What if someone changes its email ??

  7. I guess it’s possible to catch email change, then regenerate the hash :)

  8. Thanks a lot, it’s working!
    What if I need to update BP, is it still working?
    Nothing new about a plugin so far?
    Thanks a lot

  9. I’m using it with live projects, so I’ll post an update if it will stop working in some day.

  10. I have one weird thing.
    On my registration page, I still have the field for the Username.
    It’s working without filling in this gap but it would be nice if it doesn’t appear at all..
    Thanks a lot

  11. Then, you should hide it by editing the theme’s CSS.

  12. Ok thanks a lot,

    Do you have any hint how I can do this? :)

  13. Not really, it depends on your theme.
    But I guess you’ll need some basic CSS and HTML knowledge, and a Firefox extension called Firebug will be also useful.

  14. I know this post is old, but thank you very much for this solution – it’s not as dirty as you think, if you keep track of core file edits as we do.

    This worked like a charm, and I’m really grateful to you.

  15. This worked great…thanks!

  16. Thanks for this two-year-old post. Set me on the right track for a project dropped on me this afternoon. Cheers.