Skip to content

Instantly share code, notes, and snippets.

@raviousprime
Created September 6, 2018 19:22
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 raviousprime/d822dab7403858500159d94cc6e01278 to your computer and use it in GitHub Desktop.
Save raviousprime/d822dab7403858500159d94cc6e01278 to your computer and use it in GitHub Desktop.
Delete notification without marking as read
/**
* 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