Articles Comments

Moderate new user registration in BuddyPress

SHARE: Share

BuddyPress doesn’t look like a perfect script to me, it has some missing parts.. One of these extremely important parts is the option to moderate new user registration (check them for spam).

Anyways, I am not going to waste your time with stories so, here’s what you have to do (or pay me to do it :) ). This will allow you to be the one who receives the activation e-mail instead of the user. After you check the new profile you can click the activation link or just forward it to the new user.

  1. Back up everything! Yeah, your entire server, that`s a good thing to do at least once a month!
  2. Open up wp-content/plugins/buddypress/bp-core/bp-core-signup.php
    Go to line 524, you should see this:

    $to = apply_filters( 'bp_core_activation_signup_user_notification_to', $user_email );

    In the above piece of code replace $user_email with $admin_email or ‘youremail@yourserver.com’

  3. Now, 3 lines below that you have:
    $message = apply_filters( 'bp_core_activation_signup_user_notification_message', $message );

    Replace that line with:

    $message = apply_filters( 'bp_core_activation_signup_user_notification_message', $message." User e-mail: ".$user_email );

    As you can see, I have added the new users’ e-mail address to the e-mail with the activation link. This way you’ll know which activation link belongs to which user.

    Save the file and overwrite the old one (you already have a backup from step 1, so no worries)
  4. Now, go to wp-content/plugins/buddypress/bp-themes/bp-default/registration/register.php, line 225, and find this:

    <?php _e( 'You have successfully created your account! To begin using this
    site you will need to activate your account via the email we have just sent to
    your address.', 'buddypress' ) ?>


    Change the existing text with something nice.

    Save the file & overwrite the old one.

Enjoy!

P.S. Oh, if this was useful and you feel like donating, buy me a beer. Thaaanks! :)

Filed under: Web development · Tags: , , ,

7 Responses to "Moderate new user registration in BuddyPress"

  1. r-a-y (1 comments) says:

    No need to hack bp-core-signup.php when there are filters available for you to override these options!

  2. Niclas (3 comments) says:

    Hi, this is a great workaround!

    Is it possible to send one of the extended profile fields in the mail also? For example if I want to sent a Company field name so the reciver of the mail could see what company that want to register?

    I would be very pleased for a response!

  3. Joseph (21 comments) says:

    Everything is possible in the IT field. :)

  4. Niclas (3 comments) says:

    Ok, any idea how?

  5. Joseph (21 comments) says:

    $message = apply_filters( 'bp_core_activation_signup_user_notification_message', $message." User e-mail: ".$user_email );

    In the example above I have added an extra field, the users e-mail address.
    The same way you can add what you need.

    If what you need to add doesn’t have a variable (ie. $user_email), you can create a mysql query and echo the result. It should be easy.

  6. Niclas (3 comments) says:

    Hmm…strange. I dont really get this. I tell you, I´m no good at PHP but the only field a can pass are the $user_id. I´v tried with £firstname, $username without any luck. Could you provide me any more examples?

  7. olizilla (1 comments) says:

    Thanks for the tip, it saved me a lot of hunting.
    I heeded r-a-y’s advice, so instead of altering bp-core-signup.php I added it as a filter:

    function filter_replace_with_moderator_email($user_email) {
    return get_site_option( "admin_email" );
    }
    add_filter('bp_core_activation_signup_user_notification_to', 'filter_replace_with_moderator_email');

    to the register.php of my buddypress theme. Perhaps there is a better place to put this code, but it works, and as it’s in the theme, it will survive if buddypress gets upgraded.

Leave a Reply