Skip to:
Content
Pages
Categories
Search
Top
Bottom

Edit bp-members-functions.php to include Username

  • @ramatheron

    Participant

    Some of my users were having trouble logging in after they registered using a space in their username. This meant that the space would be changed into a dash, but this wasn’t clear to the users.

    A good solution would be to include the corresponding username in the activation e-mail. I’m almost sure this can be done in the bp-members-functions.php file, but I have no idea how.

    Here’s the code I think needs editing:


    function bp_core_signup_send_validation_email( $user_id, $user_email, $key ) {

    $activate_url = bp_get_activation_page() .”?key=$key”;
    $activate_url = esc_url( $activate_url );

    $from_name = ( ” == bp_get_option( ‘blogname’ ) ) ? __( ‘BuddyPress’, ‘buddypress’ ) : esc_html( bp_get_option( ‘blogname’ ) );

    $message = sprintf( __( “Thanks for registering! To complete the activation of your account please click the following link:nn%1$snn”, ‘buddypress’ ), $activate_url );
    $subject = ‘ ‘ . __( ‘Activate Your Account’, ‘buddypress’ );

    // Send the message
    $to = apply_filters( ‘bp_core_signup_send_validation_email_to’, $user_email, $user_id );
    $subject = apply_filters( ‘bp_core_signup_send_validation_email_subject’, $subject, $user_id );
    $message = apply_filters( ‘bp_core_signup_send_validation_email_message’, $message, $user_id, $activate_url );

    wp_mail( $to, $subject, $message );

    do_action( ‘bp_core_sent_user_validation_email’, $subject, $message, $user_id, $user_email, $key );
    }



    I’m also using the ‘BuddyPress Usernames Only’ plugin, if that’s useful information.

    Can anyone help me?

    Thanks in advance,
    RaMa

Viewing 7 replies - 1 through 7 (of 7 total)
  • @shanebp

    Moderator

    Editing core files is not recommended, but try this, untested:

    After this:
    `
    $message = apply_filters( ‘bp_core_signup_send_validation_email_message’, $message, $user_id, $activate_url );
    `

    Put this:
    global $wpdb;

    $username = $wpdb->get_var( “SELECT user_login FROM $wpdb->users WHERE ID = $user_id” );

    $message .= ” Your user name for log-in is ” . $username;

    @ramatheron

    Participant

    Nope, that breaks my site. Thanks for thinking with me though :)

    @djpaul

    Keymaster

    Definitely never edit core files.

    @ramatheron

    Participant

    Is there another solution?

    @ethanvan

    Spectator

    I don’t believe there is a hook for that in BP yet but I could be mistaken. @djpaul is right about editing core files.

    @djpaul is there a hook for this in BP?

    @modemlooper

    Moderator

    To change message text use a function and filter

    `function my_message_text($message) {
    Message code here for anything you want in email
    }
    add_filter( ‘bp_core_signup_send_validation_email_message’, ‘my_message_text’ );`

    @ramatheron

    Participant

    Thanks, modemlooper. I think that would have worked if I tried to figure it out. User ‘aces’ posted a reply in another thread with the link below though. It was exactly what I needed :)

    http://wordpress.stackexchange.com/questions/66204/showing-the-users-username-in-registration-email-or-activation-page-with-buddyp

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Edit bp-members-functions.php to include Username’ is closed to new replies.
Skip to toolbar