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.
This commit is contained in:
Ian Dunn 2022-05-03 12:36:16 -07:00
parent c6d7bbb7c1
commit 428cde283c
No known key found for this signature in database
GPG key ID: 99B971B50343CBCB

View file

@ -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'
);
}