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.

add_action('bp_core_signup_user','bp_set_notification_default',100,1);
  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) {
      update_user_meta($user_id,$key,'no');
    }
}

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.

PyroCMS, Consider Me Impressed

Just a quick plug. I’m building my first project with PyroCMS. I was already a fan of Codeigniter, the core behind PyroCMS, but so far I’m impressed with just how easy it is to set up and extend CI with PryoCMS if you’re already familiar with CI and MVC. It lacks the community that WP has supporting it, so you’ll need to be prepared to do some custom code. But in a lot of cases it’s the ability to customize that you really need, but you don’t want to have to build a backend from scratch. PyroCMS seems to serve this purpose very effectively.