Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/29/2020 05:32:05 PM (5 years ago)
Author:
boonebgorges
Message:

Don't delete user data on delete_user hook on Multisite.

The new function bp_remove_user_data_on_delete_user_hook(), which defaults
to false on Multisite and true otherwise, helps BuddyPress to differentiate
between the use of wp_delete_user() to delete a user account from an
installation (typical on non-Multisite) and its use to remove a user from
a site in a Multisite instance.

Props imath.

Fixes #8175.

File:
1 edited

Legend:

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

    r12303 r12605  
    758758}
    759759add_action( 'wpmu_delete_user',  'friends_remove_data' );
    760 add_action( 'delete_user',       'friends_remove_data' );
    761760add_action( 'bp_make_spam_user', 'friends_remove_data' );
     761
     762/**
     763 * Deletes user Friends data on the 'delete_user' hook.
     764 *
     765 * @since 6.0.0
     766 *
     767 * @param int $user_id The ID of the deleted user.
     768 */
     769function bp_friends_remove_data_on_delete_user( $user_id ) {
     770    if ( ! bp_remove_user_data_on_delete_user_hook( 'friends', $user_id ) ) {
     771        return;
     772    }
     773
     774    friends_remove_data( $user_id );
     775}
     776add_action( 'delete_user', 'bp_friends_remove_data_on_delete_user' );
    762777
    763778/**
Note: See TracChangeset for help on using the changeset viewer.