Wordpress Plugin: GK IP Country Detector

in #utopian-io7 years ago

Today I present you with another wordpress plugin that allows wordpress powered sites to easily detect the IP as well as the relevant country of the visitor so as to take appropriate action. While there might be other similar plugins, yet our solution is light weight, and relies on two web services (one main and another backup) making it a very straight forward an reliable approach.


image.png

Purpose of the plugin

The plugin essentially aims at providing the developer of wordpress solutions with ease of access to a function that connects to APIs of either freegeoip.net (as the main site) or alternatively www.geoplugin.net (as the backup service) to query for the country of the visitor based on the detected IP. Many times we receive requests from clients and/or developers for such functionality, so thought to make it easily accessible via this plugin.

Coding the plugin

The plugin essentially works in the background, and makes the function gk_map_ip_country available to be used across other code, so that when called anywhere, this function would allow grabbing the two letter identifier of the relevant visitor country.
The code is written as pure PHP and relies on $_SERVER content to identify the IP.

Utilizing the plugin

After setting up the plugin, anywhere in the code, particularly on front end functionality, the aforementioned function gk_map_ip_country() can now be called within code, and used to detect the relevant 2 letter relevant country code. Sample codes include 'US', 'CA', 'GB', 'IN',... and then decide upon which action needs to be taken. This can also be alternatively used to display the country for the visitor as well.

Downloading the plugin

The plugin is available on the official GitHub repository.
Being the sole contributor (and creator) of the plugin, there are currently no branches/forks/gists/pull requests, and all the code is openly accessible via above link. The most recent commit is accessible via this link
Feel free to check it out and use it. Let me know should you have any questions :)

Thank you

@mcfarhat



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Neat! Could be useful for a webshop that then can serve up region specific collections and prices for example!

Why are you posting this unrelated article here and giving yourself an upvote @santosh0877? That's not how this works :(

It is possible to identify visitors by IP.

This post has received gratitude of 1.00 % from @jout

Qurator
Your Quality Content Curator
This post has been upvoted and given the stamp of authenticity by @qurator. To join the quality content creators and receive daily upvotes click here for more info.

Qurator's exclusive support bot is now live. For more info click HERE or send some SBD and your link to @qustodian to get even more support.

Thank you for the contribution. It has been approved.

You can contact us on Discord.
[utopian-moderator]

Hey @mcfarhat I am @utopian-io. I have just upvoted you!

Achievements

  • Seems like you contribute quite often. AMAZING!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

Congratulations! This post has been upvoted from the communal account, @minnowsupport, by mcfarhat from the Minnow Support Project. It's a witness project run by aggroed, ausbitbank, teamsteem, theprophet0, someguy123, neoxian, followbtcnews/crimsonclad, and netuoso. The goal is to help Steemit grow by supporting Minnows and creating a social network. Please find us in the Peace, Abundance, and Liberty Network (PALnet) Discord Channel. It's a completely public and open space to all members of the Steemit community who voluntarily choose to be there.

If you would like to delegate to the Minnow Support Project you can do so by clicking on the following links: 50SP, 100SP, 250SP, 500SP, 1000SP, 5000SP. Be sure to leave at least 50SP undelegated on your account.

Coin Marketplace

STEEM 0.16
TRX 0.16
JST 0.030
BTC 57806.13
ETH 2453.64
USDT 1.00
SBD 2.36