Skip to content

Commit

Permalink
Merge pull request #36 from boxuk/PEAK-1246-registration-marketing-pr…
Browse files Browse the repository at this point in the history
…eferences

[J#PEAK-1246] Fixes user consent POST field on save_user_consent_on_registration
  • Loading branch information
a6software authored May 23, 2019
2 parents fb9aa40 + e9c8e79 commit 2c95ff3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions includes/class-gdpr.php
Original file line number Diff line number Diff line change
Expand Up @@ -332,15 +332,19 @@ 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 ) ) {

$consents = array_map( 'sanitize_text_field', array_keys( wp_unslash( $user_consents ) ) );
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
Expand Down

0 comments on commit 2c95ff3

Please sign in to comment.