Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
01/05/2016 03:23:11 PM (6 years ago)
Author:
boonebgorges
Message:

Delete a user's notifications when the user is deleted.

Props henry.wright, Mamaduka.
Fixes #6681.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-notifications/bp-notifications-functions.php

    r10417 r10437  
    422422}
    423423
     424/**
     425 * Delete a user's notifications when the user is deleted.
     426 *
     427 * @since 2.5.0
     428 *
     429 * @param int $user_id ID of the user who is about to be deleted.
     430 * @return int|bool The number of rows deleted, or false on error.
     431 */
     432function bp_notifications_delete_notifications_on_user_delete( $user_id ) {
     433    return BP_Notifications_Notification::delete( array(
     434        'user_id'           => $user_id,
     435        'item_id'           => false,
     436        'secondary_item_id' => false,
     437        'component_action'  => false,
     438        'component_name'    => false,
     439    ) );
     440}
     441add_action( 'wpmu_delete_user', 'bp_notifications_delete_notifications_on_user_delete' );
     442add_action( 'delete_user', 'bp_notifications_delete_notifications_on_user_delete' );
     443
    424444/** Mark **********************************************************************/
    425445
Note: See TracChangeset for help on using the changeset viewer.