Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save BhargavBhandari90/755e428108fc43de56e7884d78218dcb to your computer and use it in GitHub Desktop.
Save BhargavBhandari90/755e428108fc43de56e7884d78218dcb to your computer and use it in GitHub Desktop.
Manipulate email notification setting for user when they register for buddypress/buddyboss
<?php
function bpdev_set_email_notifications_preference( $user_id ) {
//I am putting some notifications to no by default and the common ones to yes to enable it.
//ref. https://bp-tricks.com/snippets/changing-default-buddypress-notifications-settings and BP forum
$settings_keys = array(
'notification_activity_new_mention' => 'yes',
'notification_activity_new_reply' => 'yes',
'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' => 'yes',
);
foreach( $settings_keys as $setting => $preference ) {
bp_update_user_meta( $user_id, $setting, $preference );
}
}
add_action( 'user_register', 'bpdev_set_email_notifications_preference');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment