• Resolved Tim

    (@surferjoe)


    Is it possible to manually add the cookie notice to the footer of my website using PHP. The reason I would like to do this is so that I can add my own GEOIP rule to display only in EU countries and I currently use Cloudflare GEOIP headers. I have tried activating the GEOIP setting but on doing this the cookie notice stops displaying and I am testing from UK IP address?

Viewing 1 replies (of 1 total)
  • Plugin Author Moove Agency

    (@mooveagency)

    Hi @surferjoe,

    You can align the code snippet below to show:

    add_action( 'gdpr_extend_loc_data', 'gdpr_geoip_sample_data', 99, 1 );
    function gdpr_geoip_sample_data( $data ) {
      // Allowed string 'true' to show the banner and 'false' to keep hidden
      $display_banner = 'true';
    
      // This should be the geoIP checker, create the gdpr_geo_checker function which return true or false
      if ( ! gdpr_geo_checker( $user_ip ) ) :
        // Hiding the banner
        $display_banner = 'false';
      endif;
    
      $data['display_cookie_banner']    = $display_banner;
      return $data;
    }

    Hope this helps.

Viewing 1 replies (of 1 total)

The topic ‘Manually add cookie notice to footer using PHP function?’ is closed to new replies.