Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

a) I would like the person's username to be included in their activation email once they have registered.

e.g. Activation email would look like: Thanks for registering! To complete the activation of your account please click the following link and log in using USERNAME and password you chose: activation link url

Or if that is not possible.

b) If it is easier to display it on the page once the activation link has been clicked in the email, I would like to show the person's username there.

e.g. Activation page: Your account was activated successfully! You can now log in with the username USERNAME and password you provided when you signed up.

share|improve this question

closed as off-topic by toscho Aug 2 at 20:54

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer 1

up vote 1 down vote accepted

You can add the username to the activation e-mail by adding this code either to the bp-custom.php or to the theme's functions.php file

add_filter('bp_core_signup_send_validation_email_message', 'add_username_to_activation_email',10,3);

function add_username_to_activation_email($msg, $u_id, $activation_url) {
    $username = $_POST['signup_username'];
    $msg .= sprintf( __("After successful activation, you can log in using your username (%1\$s) along with password you choose during registration process.", 'textdomain'), $username);
    return $msg;
}

EDIT: You are right, if the user used a space in his username, Buddypress will not show him an error and the registration process will continue. The next time user tries to log-in using his username with a space, the log-in process will fail. So we have to replace $username = $_POST['signup_username'] as follows:

add_filter('bp_core_signup_send_validation_email_message', 'add_username_to_activation_email',10,3);

function add_username_to_activation_email($msg, $u_id, $activation_url) {
    // $username = $_POST['signup_username'];
    $userinfo = get_userdata($u_id);
    $username = $userinfo->user_login;
    $msg .= sprintf( __("After successful activation, you can log in using your username (%1\$s) along with password you choose during registration process.", 'textdomain'), $username);
    return $msg;
}
share|improve this answer
    
Thank you very much Ahmad, that worked the first time I tried! The problem I'm having is that if a user signs up with the username Future Diamond, the email sends the username Future Diamond. But the correct login username to BuddyPress is Future-Diamond (a hyphen is added in place of the space). How do I get the email to show the hyphen? –  user20834 Sep 26 '12 at 0:28
    
The hyphen comes up now perfectly Ahmad, thank you. –  Tanya Sep 27 '12 at 3:42
    
You are welcome. –  Ahmad M Sep 27 '12 at 10:05

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