Viewing 3 replies - 1 through 3 (of 3 total)
  • I’m the author of the Category Country Aware WordPress (CCA) plugin. By using the CCA plugin together with a single line edit of Cookie Notice’s code I’m displaying the Cookie bar to EU visitors only.

    For those happy modifying code: somewhere around line 665 in cookie-notice.php immediately below
    public function cookie_setted() {
    insert a new line
    if (class_exists('CCAgeoip') && ! apply_filters( 'cca_is_EU',FALSE)) return TRUE;

    If you have the CCA plugin installed then your good to go.

    I’m not sure if I’ve picked the best place in cookie-notice.php for the check (done in a hurry as I’m away next week) but it works for me.

    The filter checks visitor IP and returns true for this list of country codes “BE,BG,CZ,DK,DE,EE,IE,GR,ES,FR,HR,IT,CY,LV,LT,LU,
    HU,MT,NL,AT,PL,PT,RO,SI,SK,FI,SE,GB”. You can alternatively use your own list in the filter e.g.
    apply_filters('cca_is_EU',TRUE,"YO,UR,LI,ST"))

    You can also check for specific countries apply_filters(cca_geoip_lookup,'ccode') == "IT" e.g. to cater for stricter Italian laws

    Issues:

    You will have to reinsert this line whenever the Cookie Notice plugin is updated. (I’d be more than happy if dFactory added this filter to the Cookie plugin!).

    Don’t do it if you are also using a caching plugin. Caching and geo-location do not usually work properly together. I’m also the author of Country Caching Extensions for Zen Cache and WPSC but even I don’t recommend their use with the above until modified to work efficiently with an EU “group” (another couple of weeks).

    Whoops no code needed.

    To display the Cookie Notice bar to EU visitors only:

    Install the CCA Plugin

    Go to Dashboard->Settings->Category Country Aware->Countries scroll down, enable the Cookie Notice check box and save settings.

    Job Done. The CCA plugin will identify the visitors location and via a hook tell Cookie Notice whether or not to display the bar.

    Its easy to test whether its working – see this post.

    Thanks to Bartosz / dfactory one of his answers in another post enabled me to identify a solution.

    Plugin Author dFactory

    (@dfactory)

    Thanks for the write up.

    I have not heard of this plugin before – looks useful with combination with CN.

    Regards,
    Bartosz / dfactory

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to GEO target cookie bar or its content?’ is closed to new replies.