From 428cde283c643687258f9c375faf640421e1144a Mon Sep 17 00:00:00 2001 From: Ian Dunn Date: Tue, 3 May 2022 12:36:16 -0700 Subject: [PATCH] Contributors: Clear object cache when resetting profile data. BuddyPress sets it infinitely, so for some users it would be awhile before it would be pushed out organically. --- plugins/wporg-5ftf/includes/xprofile.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/plugins/wporg-5ftf/includes/xprofile.php b/plugins/wporg-5ftf/includes/xprofile.php index 87b5471..e50d65e 100644 --- a/plugins/wporg-5ftf/includes/xprofile.php +++ b/plugins/wporg-5ftf/includes/xprofile.php @@ -173,6 +173,9 @@ function get_contributor_user_data( $user_id ) { /** * Reset the 5ftF data on a user's profile. + * + * This deletes directly from the database and object cache -- rather than using something like + * `BP_XProfile_Field::delete()` -- because w.org/5 runs on a different network than profiles.w.org. */ function reset_contribution_data( $user_id ) : void { global $wpdb; @@ -187,4 +190,14 @@ function reset_contribution_data( $user_id ) : void { FIELD_IDS['hours_per_week'], FIELD_IDS['team_names'], ) ); + + wp_cache_add_global_groups( 'bp_xprofile_data' ); + wp_cache_delete_multiple( + array( + $user_id . ':' . FIELD_IDS['sponsored'], + $user_id . ':' . FIELD_IDS['hours_per_week'], + $user_id . ':' . FIELD_IDS['team_names'], + ), + 'bp_xprofile_data' + ); }