Support » Plugin: GeoIP Detection » Get Country on cached pages (with AJAX?)

  • Resolved haraldla

    (@haraldla)


    I like the plugin very much and it’s working smoothly without caching.

    But what I’m trying to do is to show a contact section on each page depending on the users country. So in this case I can’t use the plugins option to disable cache for those pages, because then all pages would be excluded from caching.

    I also tried an ajax call (like here https://wordpress.org/support/topic/js-api/#post-7318233) but got an error 400.

    Would be glad if I get this to work. Thanks for your help and for developing such a great plugin.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Benjamin Pick

    (@benjaminpick)

    The mentioned work (https://github.com/yellowtree/geoip-detect/pull/46/files#diff-f03c876c5928000ca61138c1b1b52016) is way more complete than the example you quote. If you use it, change the function names though.

    I just decided to implement basic support (server-side) soon, instead of aiming for all-or-nothing and thus not doing it (implementing the shortcodes via AJAX will be tricky!).

    Plugin Author Benjamin Pick

    (@benjaminpick)

    Oh your next question will probably be: “when?” – That’s always hard to tell for non-paid work 🙂 But think in terms of months – subscribe the ajax thread and you’ll be notified.

    Wow, great! The mentioned Ajax Call above is working now!
    Where can I buy you a coffee 🙂
    So I have to be careful with plugin upgrades until the functionality is in the official release?

    Greetings from Austria,
    Harald

    I just discovered the real cause of the error 400:
    When I was logged in everything was fine with the ajax script. Only for not logged in users the error 400 was thrown.
    So I figured out, that one line of code was missing to get this to work for all (anonymous) users:

    add_action( ‘wp_ajax_nopriv_wpst_get_country’, ‘wpst_get_country’ );

    Plugin Author Benjamin Pick

    (@benjaminpick)

    No if you copied the code from the forum thread, it is only using API functions so updates should be fine. Yes nopriv does exactly what you are saying.

    Plugin Author Benjamin Pick

    (@benjaminpick)

    I have started working on this:
    https://github.com/yellowtree/geoip-detect/pull/59

    Plugin Author Benjamin Pick

    (@benjamin4)

    Beta is released now (2.11) …

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Get Country on cached pages (with AJAX?)’ is closed to new replies.