Skip to content

Instantly share code, notes, and snippets.

@goranefbl
Last active October 6, 2025 10:43
Show Gist options
  • Select an option

  • Save goranefbl/5c31d4bb3307d45ec404211c055f630d to your computer and use it in GitHub Desktop.

Select an option

Save goranefbl/5c31d4bb3307d45ec404211c055f630d to your computer and use it in GitHub Desktop.
GDPR Hide boxes
<?php
// Only allow users with specific meta field
add_filter('wpgens_loyalty_should_allow_points_for_user', function ($should_allow, $user_id, $source, $type, $points_delta) {
$is_gdpr_points_consent = get_user_meta($user_id, 'gdpr_points_consent', true);
return $is_gdpr_points_consent === 'yes';
}, 10, 5);
add_filter('wpgl_show_points_earning_box', function ($should_show) {
if (is_user_logged_in()) {
$is_gdpr_points_consent = get_user_meta(get_current_user_id(), 'gdpr_points_consent', true);
return $is_gdpr_points_consent === 'yes';
}
});
add_filter('wpgens_loyalty_show_points_redemption_block', function ($should_show) {
if (is_user_logged_in()) {
$is_gdpr_points_consent = get_user_meta(get_current_user_id(), 'gdpr_points_consent', true);
return $is_gdpr_points_consent === 'yes';
}
});
// Block based checkout - hide points earnings notice
add_filter('body_class', function ($classes) {
if (is_user_logged_in()) {
$user_id = get_current_user_id();
$consent = get_user_meta($user_id, 'gdpr_points_consent', true);
if ($consent === 'yes') {
$classes[] = 'gdpr-points-consent-yes';
} else {
$classes[] = 'gdpr-points-consent-no';
}
} else {
$classes[] = 'gdpr-points-consent-guest';
}
return $classes;
});
add_action('wp_head', function () {
?>
<style>
.gdpr-points-consent-no .wpgens-points-earning-notice {
display: none !important;
}
</style>
<?php
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment