• OMP

    (@spiderdudececil)


    Essentially, a way of determining a user’s location (based on IP or GPS?) and then disabling specific external API calls for that user. So, for example, users from China won’t need to experience slow load times waiting for requests to Analytics, Gravatar, WP.com, Facebook, etc, to return a timeout, if those services are not accessible from within the country.

    Any plugin, or plugin combinations, code snippets, configurations, or just any insight into how something like that could be achieved would be helpful and much appreciated. Tried looking around the forums and the greater webs for this particular need, but no luck so far, so I thought best to reach out directly to the community and see if anyone has handled something like this before.

Viewing 4 replies - 1 through 4 (of 4 total)
  • I use the free https://www.cloudflare.com/. You can block countries that are not relevant.

    Thread Starter OMP

    (@spiderdudececil)

    Thanks, kmessigner. I guess I may not have been very clear in my question. I don’t wish to block countries altogether. simply inform a WordPress instant to not do (or to do) something when a user from a specific country accesses it.

    Is there a way to accomplish that? And how?

    Moderator bcworkz

    (@bcworkz)

    Something is possible, the specifics depend on how an external call ended up on the user’s browser in the first place. A user’s IP is always available in $_SERVER, though in some cases it may be a load balancer or proxy, which should still reflect the user’s country of origin. That IP can be checked against an array of IP values. If there’s a match, do not output the external reference.

    A lot of references, if done properly through the wp_enqueue_scripts action, could be suppressed by removing the function doing the output from the global $wp_filters array. In other cases, if the output is caused through other mechanisms, that mechanism, be it a template or custom theme or plugin function, would need to be modified. The latter is less reliable since modifications can be lost during updates. wp_enqueue_scripts actions can be removed through an independent plugin so are safe from updates.

    Thread Starter OMP

    (@spiderdudececil)

    Thanks for your feedback, bcworkz. So, let’s see if I understand correctly:

    I could potentially run a custom plugin that keeps a look out for user browser sessions with an IP which, if it matches a range from a specified region, will then call a function which will then disable -lets say – a wordpress.com API call by the Jetpack plugin, but only for that user’s session, and not for any other concurrent users (with a different IP range)?

    I’m getting my head all twisted around trying to sort this one out.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Disable calls to certain domains only for users from certain countries’ is closed to new replies.