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.

About Mike Van Winkle

Ugh. I hate writing profiles. Just read the blog dude.

Comments

  1. Daniel says:

    This looks great, but could you outline which file we need to enter the code on?

  2. Daniel says:

    Nvm, i chucked it into the theme’s function.php and its working like a charm.

    Thanks a bunch!

    • functions.php should work, but in an ideal world you put all your BuddyPress mods in a custom plugin. The reason for this is that some buddypress hooks cannot be accessed from the theme functions.php because they have already fired before the file is loaded. So if you are making lots of mods to BP core you should really do a custom plugin.

  3. Shawn says:

    Okay so I added the code to my functions.php file, right before the code I am using to hide my admin account from the activity stream. I hope it works, but guess I will find out when someone finally joins.

    Have you by any chance any idea on how to hide the admin account from not showing up on the “Members Directory” page?

  4. foobarph says:

    you can also go to your cpanel > phpmyadmin > ur database > sql

    then execute this sql statement

    update wp_usermeta
    set meta_value = ‘no’
    where meta_key like ‘notification_%’

    sleek!

  5. areeb says:

    U Rock

  6. Good day! This is my first visit to your blog!
    We are a team of volunteers and starting a new
    initiative in a community in the same niche. Your blog provided
    us valuable information to work on. You have done a marvellous job!

  7. Kiera says:

    Wonderful beat ! I would like to apprentice while you amend your site, how can i
    subscribe for a weblog site? The account helped me a acceptable deal.

    I have been a little bit acquainted of this your
    broadcast offered vibrant transparent concept

    my website: seo Google (Kiera)

  8. Greetings! Quick question that’s completely off topic.

    Do you know how to make your site mobile friendly?
    My website looks weird when viewing from my apple iphone. I’m trying to find a template or plugin that might be able to fix this issue.
    If you have any recommendations, please share. With thanks!

  9. You’re so interesting! I do not suppose I’ve
    truly read through something like that before. So nice to find somebody with original thoughts on this subject matter.
    Seriously.. thanks for starting this up. This web site is something that is
    required on the internet, someone with some originality!

  10. Very soon this website will be famous among all blogging
    people, due to it’s pleasant articles

  11. Hսm êtes ѵous certain de ce que vous nous écrivez ??

  12. facebook says:

    Article writing is also a excitement, if you
    know then you can write or else it is complicated to write.

  13. Peculiar article, jjust what I wanted to find.

  14. Les Cougars sont deuxi猫me champion graines d茅fendre derri猫re et talentueux Los Gatos (10 0), qui est dirig茅 par l’un des de la nation la plus recherch茅e apr猫s les quarts. Les Wildcats ont l’une des s茅ries les plus int茅ressantes de confrontations soir茅e d’ouverture contre l’ennemi saint Fran莽ois de Mountain View (4 6).

  15. Becoming a mother is one of the most beautiful and miraculous events in a woman’s life. However, having a new baby often times renders a mom sleep and time deprived and far from her former hip self. With a few helpful hints, new moms, and not so new moms can feel beautiful and pulled together in just a few minutes a day. After all, taking care of yourself and making sure you feel good will only enhance your ability to be a good mom. 1. Rest as much as possible. Nap when your baby naps and try to get to bed early every night.

  16. What’s up, after reading this amazing piece of writing i am as
    well happy to share my experience here with mates.

  17. Hmm is anyone else experiencing problems with the images on this blog loading?
    I’m trying to determine if its a problem on my end or if it’s
    the blog. Any suggestions would be greatly appreciated.

  18. Paragraph writing is also a fun, if you be acquainted with
    then you can write if not it is complex to write.

Speak Your Mind

*