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.
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
Posted on Utopian.io - Rewarding Open Source Contributors
Neat! Could be useful for a webshop that then can serve up region specific collections and prices for example!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
yep 100% !
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
To know how to speedup WordPress website.
https://steemit.com/speed/@santosh0877/best-ways-to-speed-up-wordpress-website
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Why are you posting this unrelated article here and giving yourself an upvote @santosh0877? That's not how this works :(
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
It is possible to identify visitors by IP.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
This post has received gratitude of 1.00 % from @jout
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Thank you
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Thank you for the contribution. It has been approved.
You can contact us on Discord.
[utopian-moderator]
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Hey @mcfarhat I am @utopian-io. I have just upvoted you!
Achievements
Community-Driven Witness!
I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!
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
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
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.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit