Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BhargavBhandari90/600c087d476384081ce7537c28e23b9c to your computer and use it in GitHub Desktop.
Save BhargavBhandari90/600c087d476384081ce7537c28e23b9c to your computer and use it in GitHub Desktop.
Turn email notification OFF for new users for BuddyBoss and BuddyPress
<?php
/**
* Disable email notification.
*
* @param integer $user_id User ID.
* @return void
*/
function buddyboss_set_email_notifications_preference( $user_id ) {
// Prevent fatal error if plugin is not available.
if ( ! function_exists( 'bp_update_user_meta' ) || empty( $user_id ) ) {
return;
}
// Setting keys.
$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',
);
// Update setting
foreach( $settings_keys as $setting => $preference ) {
bp_update_user_meta( $user_id, $setting, $preference );
}
}
add_action( 'user_register', 'buddyboss_set_email_notifications_preference' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment