Last active
June 23, 2020 18:38
-
-
Save BhargavBhandari90/600c087d476384081ce7537c28e23b9c to your computer and use it in GitHub Desktop.
Turn email notification OFF for new users for BuddyBoss and BuddyPress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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