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-groups/bp-groups-functions.php

    r12601 r12605  
    24182418}
    24192419add_action( 'wpmu_delete_user',  'groups_remove_data_for_user' );
    2420 add_action( 'delete_user',       'groups_remove_data_for_user' );
    24212420add_action( 'bp_make_spam_user', 'groups_remove_data_for_user' );
     2421
     2422/**
     2423 * Deletes user group data on the 'delete_user' hook.
     2424 *
     2425 * @since 6.0.0
     2426 *
     2427 * @param int $user_id The ID of the deleted user.
     2428 */
     2429function bp_groups_remove_data_for_user_on_delete_user( $user_id ) {
     2430    if ( ! bp_remove_user_data_on_delete_user_hook( 'groups', $user_id ) ) {
     2431        return;
     2432    }
     2433
     2434    groups_remove_data_for_user( $user_id );
     2435}
     2436add_action( 'delete_user', 'bp_groups_remove_data_for_user_on_delete_user' );
    24222437
    24232438/**
Note: See TracChangeset for help on using the changeset viewer.