Skip to:
Content
Pages
Categories
Search
Top
Bottom

set username=email in registration

Viewing 2 replies - 1 through 2 (of 2 total)

  • Venutius
    Moderator

    @venutius

    Here’s what I found:

    add_action( 'bp_core_validate_user_signup', 'custom_validate_user_signup' );
    
    function custom_validate_user_signup($result)
    {
      unset($result['errors']->errors['user_name']);
    
      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;
    }

    You would also need to copy plugins/buddypress/bp-templates/bp-nouveau (or bp-legacy ) /buddypress/members/register.php tothemes/your-child-theme/buddypress/members/register.php and edit it to remove the section that asks for the username:

    <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(); ?>" />

    omkarsawant1
    Participant

    @omkarsawant1

    hello,
    have a function set up in my register.php that copies the user-supplied username (in the registration form,) copies it over to the “Display Name” field, and hides the display name field on the registration form. This way, whatever the user entered for username will automatically be used for his/her display name. (To avoid asking the user for a name 2 times!)

    Would you like to do this? If so, I’d be glad to share my register.php file with you. Let me know. If this is not what you need, then please disregard this message.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Skip to toolbar