Contributors: Reset profile hours when pledge deactivated.

See https://github.com/WordPress/five-for-the-future/issues/169
This commit is contained in:
Ian Dunn 2022-04-28 15:05:44 -07:00
parent 834c62c0d0
commit c6d7bbb7c1
No known key found for this signature in database
GPG key ID: 99B971B50343CBCB
6 changed files with 338 additions and 4 deletions

View file

@ -170,3 +170,21 @@ function get_contributor_user_data( $user_id ) {
return $formatted_data;
}
/**
* Reset the 5ftF data on a user's profile.
*/
function reset_contribution_data( $user_id ) : void {
global $wpdb;
$wpdb->query( $wpdb->prepare( '
DELETE FROM `bpmain_bp_xprofile_data`
WHERE
user_id = %d AND
field_id IN ( %d, %d, %d )',
$user_id,
FIELD_IDS['sponsored'],
FIELD_IDS['hours_per_week'],
FIELD_IDS['team_names'],
) );
}