Last active
December 29, 2020 04:31
-
-
Save KaineLabs/873854245a3b76de5c3d8364f392ce73 to your computer and use it in GitHub Desktop.
Disable Notifications By Default
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 Notifications By Default. | |
*/ | |
function yz_disable_user_notifications_by_default( $user_id ) { | |
$notifications = array( | |
'notification_messages_new_message' => 'no', | |
'notification_activity_new_mention' => 'no', | |
'notification_activity_new_reply' => 'no', | |
'notification_groups_invite' => 'no', | |
'notification_groups_group_updated' => 'no', | |
'notification_groups_admin_promotion' => 'no', | |
'notification_groups_membership_request' => 'no', | |
'notification_membership_request_completed' => 'no', | |
'notification_friends_friendship_request' => 'no', | |
'notification_friends_friendship_accepted' => 'no', | |
'notification_starts_following' => 'no' | |
); | |
bp_settings_update_notification_settings( $user_id, $notifications ); | |
foreach ( $notifications as $option => $visibility ) { | |
update_user_meta( $user_id, 'yz_' . $option, 'off' ); | |
} | |
} | |
add_action( 'bp_core_signup_user', 'yz_disable_user_notifications_by_default' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment