From e9c8e79fd3392cb02749b379f302afac9425547d Mon Sep 17 00:00:00 2001 From: a6_chris Date: Thu, 23 May 2019 11:16:04 +0100 Subject: [PATCH] [J#PEAK-1246] Fixes user consent POST field on save_user_consent_on_registration --- includes/class-gdpr.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/includes/class-gdpr.php b/includes/class-gdpr.php index 87018c74..005beba7 100755 --- a/includes/class-gdpr.php +++ b/includes/class-gdpr.php @@ -332,7 +332,7 @@ public static function save_user_consent_on_registration( $user_id ) { GDPR_Audit_Log::log( $user_id, esc_html__( 'User registered to the site.', 'gdpr' ) ); // phpcs:disable WordPressVIPMinimum.VIP.PHPFilterFunctions.RestrictedFilter - $user_consents = filter_input( INPUT_POST, 'shipping_method', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); + $user_consents = filter_input( INPUT_POST, 'user_consents', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); // phpcs:enable WordPressVIPMinimum.VIP.PHPFilterFunctions.RestrictedFilter if ( is_array( $user_consents ) ) { @@ -340,7 +340,11 @@ public static function save_user_consent_on_registration( $user_id ) { foreach ( $consents as $consent ) { /* translators: Name of consent */ GDPR_Audit_Log::log( $user_id, sprintf( esc_html__( 'User gave explicit consent to %s', 'gdpr' ), $consent ) ); - add_user_meta( $user_id, 'gdpr_consents', $consent ); + if ( defined( 'WPCOM_IS_VIP_ENV' ) && WPCOM_IS_VIP_ENV ) { + add_user_attribute( $user_id, 'gdpr_consents', $consent ); + } else { + add_user_meta( $user_id, 'gdpr_consents', $consent ); + } } // This only happens on a POST request and should have no impact on caching. // phpcs:disable WordPressVIPMinimum.VIP.RestrictedFunctions.cookies_setcookie