Last active
October 6, 2025 10:43
-
-
Save goranefbl/5c31d4bb3307d45ec404211c055f630d to your computer and use it in GitHub Desktop.
GDPR Hide boxes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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