Welcome to the new BuddyDev Experience. If you note an issue, please let us know via contact form.

BuddyDev

Search

Controlling Default Email Preferences for Users on a BuddyPress based site

buddypress defalt user notification control-new(444x250)

Do you want to control the default email preferences for Users on your BuddyPress based site. Well, if you have used BuddyPress, you already know that a user can control his/her email preferences by visiting Settings->Email ( before 1.9, It was settings->Notification) as shown below:-

Now, the problem arises when you want to set a default preference for user before they update it on their own. BuddyPress does not have a hook to control the default behaviour.

The way it can be controlled is by updating user meta with appropriate settings when a user activates his/her account. Thanks to Ben (@somesu) I got the idea to provide the site admins the control to set the default preference.

Option 1: Use code to set the default preference.

Here is the code that you can put in your bp-custom.php to manage the preference

add_action( 'bp_core_activated_user', 'bpdev_set_email_notifications_preference');

function bpdev_set_email_notifications_preference( $user_id ) {

    //I am putting all the notifications to no by default
    //you can set the value to 'yes' if you want that notification to be enabled.
    $settings_keys = array(
        'notification_activity_new_mention'         => 'no',
        'notification_activity_new_reply'           => 'no',
        'notification_friends_friendship_request'   => 'no',
        'notification_friends_friendship_accepted'  => 'no',
        'notification_groups_invite'                => 'no',
        'notification_groups_group_updated'         => 'no',
        'notification_groups_admin_promotion'       => 'no',
        'notification_groups_membership_request'    => 'no',
        'notification_messages_new_message'         => 'no',
    );

    foreach( $settings_keys as $setting => $preference ) {

        bp_update_user_meta( $user_id,  $setting, $preference );
    }

//that's it. have fun!

}

Option 2:  BP Default Email Notification Settings Control plugin

If you are not comfortable with the code, I have put a plugin for our BuddyDev Members which gives admin the control to set the default preference for newly registered users.

Here is a screenshot to show the admin panel of the plugin:-

If you are a BuddyDev Premium member, you can download the plugin from here

Download & Installation:-

http://buddydev.com/plugins/bp-default-email-notification-settings-control/

I hope the code helps you  :) Please do let me know your thoughts in comment.

8 Responses to Controlling Default Email Preferences for Users on a BuddyPress based site

  • If only this worked for existing users.

    • Hi Russ,
      Thank you for the comment.
      That is my plan for next plugin but the only issue is users won’t be able to override those settings. Initially we don’t know whether a user has updated his/her settings or not. If we can detect that it will be super easy to do that.

  • I recently sent you an email requesting some help with one of your plugins that you helped me out with earlier. Please reply as soon as possible, for this plugin malfunctioning issue is impairing key features my site at this moment.

  • Wow… Thanks @sbrajesh for this plugin…

    Now i have set it up per code – my membership is at the moment expired – but i think it is a great plugin for all of us? ;)

    • Hi Ben,
      Thank you. Glad you implemented it and hope it certainly helps :)

      About membership, Just sent you a Pm :)

      • Hi @sbrajesh,

        thanks for your reply… and yes, it helps… :)

        I have many ideas for plugins – but i don’t have the skills to do that… xD

        now, i’m waiting for your Pm… ;)

  • Thank you, @sbrajesh:)

    I will get in touch with you, via pm the next days. ;)

Leave a Reply

Are you looking for support?

Please ask support questions in BuddyDev Forum and help us server you better. Please use comment for general discussion/feature suggestions.

Your email address will not be published. All the fields marked as * are required.

If you are posting code, please use <pre> { Your Code Block } </pre>. Example:- <pre> echo $name; </pre>

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">