Skip to content

Instantly share code, notes, and snippets.

@KaineLabs
Last active December 29, 2020 04:31
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 KaineLabs/873854245a3b76de5c3d8364f392ce73 to your computer and use it in GitHub Desktop.
Save KaineLabs/873854245a3b76de5c3d8364f392ce73 to your computer and use it in GitHub Desktop.
Disable Notifications By Default
<?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