• The plugin works great, except the GeoIP Detection is not working, so it is not excluding continents, like North and South America that do not have to comply with GDPR. I have installed/activated the GeoIP Detection plugin and downloaded the GeoLite2-City database. I selected all continents other than Europe for exclusion; however I am based in the United States and I still get the consent message every time I visit my site.

    Am I missing anything in order to get the geo detection working?

Viewing 15 replies - 16 through 30 (of 53 total)
  • @claymade Just put that code at the end of header.php. I recommend you to create a child theme and insert the code into header.php of the child theme.

    • This reply was modified 6 years, 4 months ago by Rahul.

    I have tried the code in the header and then in the footer. 2 of my sites still give me the error: “Your PHP code changes were rolled back due to an error on line 43 of file wp-content/themes/getalong/footer.php. Please fix and try saving again.” The other 2 sites let it update with the code. On the sites that allowed the update to the code, it is still showing the cookie consent popup in countries excluded. So the code isn’t working.

    @claymade The error is on footer.php. You did not remove the code from footer.php, remove that.

    This is the error when I put it on the header.

    Your PHP code changes were rolled back due to an error on line 224 of file wp-content/themes/getalong/header.php. Please fix and try saving again.

    Uncaught Error: Call to undefined function is_plugin_active() in wp-content/themes/getalong/header.php:224
    Stack trace:
    #0 wp-includes/template.php(688): require_once()
    #1 wp-includes/template.php(647): load_template(‘/home/readmk11/…’, true)
    #2 wp-includes/general-template.php(41): locate_template(Array, true)
    #3 wp-content/themes/getalong/index.php(15): get_header()
    #4 wp-includes/template-loader.php(74): include(‘/home/readmk11/…’)
    #5 wp-blog-header.php(19): require_once(‘/home/readmk11/…’)
    #6 index.php(17): require(‘/home/readmk11/…’)
    #7 {main}
    thrown

    The sites that received the update, ShulamitePodcast.com and ReadMK.com still show the cookie consent. The code is in the header not the footer. The other site is that get the error is Shulamite.com and GetAlongWithGod.com

    I think you misplaced the code on header.php.
    Where did you place the code?

    I placed it in the header.php at the bottom of the code using the theme editor.

    Okay, Then remove the code from header.php. And place this code at the end of functions.php.

    function hide_cookie_bar() {
        if( is_plugin_active( 'geoip-detect/geoip-detect.php' ) ) {
            $userInfo = geoip_detect2_get_info_from_current_ip();
            $countryCode = $userInfo->continent->code;
            if($countryCode!="EU") {
                ?>
                <style>
                #catapult-cookie-bar{
                    padding: 0px !important;
                    max-height: 0px !important;
                    min-height: 0px !important;
                }
                </style>
                <?php
            }
        }
      }
    add_action( 'wp_head', 'hide_cookie_bar' );

    I am getting this error from the sites that refused the update before:

    Your PHP code changes were rolled back due to an error on line 862 of file wp-content/themes/getalong/functions.php. Please fix and try saving again.

    Uncaught Error: Call to undefined function is_plugin_active() in wp-content/themes/getalong/functions.php:862
    Stack trace:
    #0 wp-includes/class-wp-hook.php(286): hide_cookie_bar(”)
    #1 wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters(NULL, Array)
    #2 wp-includes/plugin.php(453): WP_Hook->do_action(Array)
    #3 wp-includes/general-template.php(2614): do_action(‘wp_head’)
    #4 wp-content/themes/getalong/header.php(61): wp_head()
    #5 wp-includes/template.php(688): require_once(‘/home/readmk11/…’)
    #6 wp-includes/template.php(647): load_template(‘/home/readmk11/…’, true)
    #7 wp-includes/genera

    On the other sites that originally took the code but didn’t exclude the excluded territories I am getting this error:

    Your PHP code changes were rolled back due to an error on line 62 of file wp-content/themes/shulacast-soundbyte/functions.php. Please fix and try saving again.

    syntax error, unexpected ‘}’, expecting end of file

    OK I got the code to work on the 2 sites, but it still doesn’t prevent the pop up.I am sorry about this.

    Make sure that you copied full code. Clear server and browser cache and try again.
    I tested it on my site and it works for me.

    OK, I still can’t get it to update with the new or old code on those 2 sites. I will go look with the cache cleared. Let me know what you find.

    After clearing cache, readmk.com doesn’t show, but shulamitepodcast.com does.

    It is not showing for me on both websites.

    Thank you yes, it is not showing for me either. Do you want to work on a solution for the other 2 sites that show the error? Is this something the will be fixed in a plugin update? And do I remove the code in the future?
    Again, thank you Rahul! I am very grateful for your time and attention.

    Shulamite.com and GetAlongWithGod.com
    The error is on this line in both
    if( is_plugin_active( ‘geoip-detect/geoip-detect.php’ ) ) {

    Your PHP code changes were rolled back due to an error on line 758 of file wp-content/themes/Shulamite/functions.php. Please fix and try saving again.

    Uncaught Error: Call to undefined function is_plugin_active() in wp-content/themes/Shulamite/functions.php:758
    Stack trace:
    #0 wp-includes/class-wp-hook.php(286): hide_cookie_bar(”)
    #1 wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters(NULL, Array)
    #2 wp-includes/plugin.php(453): WP_Hook->do_action(Array)
    #3 wp-includes/general-template.php(2614): do_action(‘wp_head’)
    #4 wp-content/themes/Shulamite/header.php(98): wp_head()
    #5 wp-includes/template.php(688): require_once(‘/home/readmk11/…’)
    #6 wp-includes/template.php(647): load_template(‘/home/readmk11/…’, true)
    #7 wp-includes/general-template.php(41): locate_template(Array, true)

    #8

    Okay, I added an extra line. Replace previous code with this code.

    function hide_cookie_bar() {
        include_once(ABSPATH .'wp-admin/includes/plugin.php');
        if( is_plugin_active( 'geoip-detect/geoip-detect.php' ) ) {
            $userInfo = geoip_detect2_get_info_from_current_ip();
            $countryCode = $userInfo->continent->code;
            if($countryCode!="EU") {
                ?>
                <style>
                #catapult-cookie-bar{
                    padding: 0px !important;
                    max-height: 0px !important;
                    min-height: 0px !important;
                }
                </style>
                <?php
            }
        }
      }
    add_action( 'wp_head', 'hide_cookie_bar' );
Viewing 15 replies - 16 through 30 (of 53 total)
  • The topic ‘GeoIP Detection Not Working’ is closed to new replies.