Skip to:
Content

BuddyPress.org

Ticket #6681: 6681.3.diff

File 6681.3.diff, 1.2 KB (added by Mamaduka, 9 years ago)
  • src/bp-notifications/bp-notifications-functions.php

    diff --git src/bp-notifications/bp-notifications-functions.php src/bp-notifications/bp-notifications-functions.php
    index a0a2169..c3f1a2a 100644
    function bp_notifications_delete_notifications_from_user( $user_id, $component_n 
    421421        ) );
    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 updated 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
    426446/**