WordPress Hack: Turning Off BuddyPress Notifications By Default

By default BuddyPress has all sorts of email notifications turned on. This is great unless you have a big site with lots of activity and site-wide discussions. Then new users start getting pinged repeatedly on discussions they don’t want to follow or don’t even know they are apart of! So you may want BuddyPress to turn the notifications off by default. But there’s no clear way to do this in the admin. Well, here’s the golden function.

  function bp_set_notification_default($user_id) {
    $keys = array('notification_activity_new_mention','notification_activity_new_reply','notification_friends_friendship_accepted','notification_friends_friendship_request','notification_groups_admin_promotion','notification_groups_group_updated','notification_groups_invite','notification_groups_membership_request','notification_messages_new_message','notification_messages_new_notice');
    foreach($keys as $key) {

Please note that this function is hooked to bp_core_user_signup which means existing users still have to manually turn off notifications. But you could easily run this function on an array of user_ids to change the defaults for existing users.