Skip to:
Content

BuddyPress.org

Ticket #6681: 6681.2.diff

File 6681.2.diff, 1.2 KB (added by henry.wright, 6 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 9ff2a8d..1b6ff27 100644
    function bp_notifications_delete_notifications_from_user( $user_id, $component_n 
    420420        ) );
    421421}
    422422
     423/**
     424 * Delete a user's notifications when the user is deleted.
     425 *
     426 * @since 2.4.0
     427 *
     428 * @param int $user_id ID of the user who is about to be deleted.
     429 *
     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
     434        return BP_Notifications_Notification::delete( array(
     435                'user_id'           => $user_id,
     436                'item_id'           => false,
     437                'secondary_item_id' => false,
     438                'component_action'  => false,
     439                'component_name'    => false
     440        ) );
     441}
     442add_action( 'wpmu_delete_user', 'bp_notifications_delete_notifications_on_user_delete' );
     443add_action( 'delete_user', 'bp_notifications_delete_notifications_on_user_delete' );
     444
    423445/** Mark **********************************************************************/
    424446
    425447/**