Created
September 6, 2018 19:22
-
-
Save raviousprime/d822dab7403858500159d94cc6e01278 to your computer and use it in GitHub Desktop.
Delete notification without marking as read
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
/** | |
* Delete single notification. | |
* | |
* @param BP_Notifications_Notification $notification Notification object. | |
*/ | |
function buddydev_delete_notification_on_single_update( $notification ) { | |
if ( $notification->is_new ) { | |
return; | |
} | |
BP_Notifications_Notification::delete_by_id( $notification->id ); | |
} | |
add_action( 'bp_notification_after_save', 'buddydev_delete_notification_on_single_update' ); | |
/** | |
* Delete on bulk update of notifications. | |
* | |
* @param array $update_args Update args. | |
* @param array $where_args Where args. | |
*/ | |
function buddydev_delete_notifications_on_bulk_update( $update_args, $where_args ) { | |
if ( empty( $update_args ) || ! empty( $update_args['is_new'] ) ) { | |
return; | |
} | |
BP_Notifications_Notification::delete( $where_args ); | |
} | |
add_action( 'bp_notification_before_update', 'buddydev_delete_notifications_on_bulk_update', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment