Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/29/2020 05:32:05 PM (4 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-xprofile/bp-xprofile-functions.php

    r12555 r12605  
    848848}
    849849add_action( 'wpmu_delete_user',  'xprofile_remove_data' );
    850 add_action( 'delete_user',       'xprofile_remove_data' );
    851850add_action( 'bp_make_spam_user', 'xprofile_remove_data' );
     851
     852/**
     853 * Deletes user XProfile data on the 'delete_user' hook.
     854 *
     855 * @since 6.0.0
     856 *
     857 * @param int $user_id The ID of the deleted user.
     858 */
     859function xprofile_remove_data_on_delete_user( $user_id ) {
     860    if ( ! bp_remove_user_data_on_delete_user_hook( 'xprofile', $user_id ) ) {
     861        return;
     862    }
     863
     864    xprofile_remove_data( $user_id );
     865}
     866add_action( 'delete_user', 'xprofile_remove_data_on_delete_user' );
    852867
    853868/*** XProfile Meta ****************************************************/
Note: See TracChangeset for help on using the changeset viewer.