Contact Form 7: Add Country By IP Shortcode To Email

Copy this code to your theme’s functions.php and use [country_by_ip] shortcode/tag ANYWHERE to print the visitor’s country by his IP address with CF7. It uses ipinfo.io’s free API, detects the visitor’s IP address and adds CF7 shortcode/tag to use in the email body for example. Enjoy!

3rd Party Integration: Add Geolocation To Service Posts

Copy this code to your theme’s functions.php and each call your ‘3rd party integrations’ plugin will make after a visitor submission (For CRMs API, for example), it will include the Country, City & State of the visitor by his IP address.  

How To Get The Real Visitor’s IP With PHP

The following function will return the visitor’s IP address: Usage: