This documentation page is for Quform version 1 and may not be applicable for Quform 2 click here to visit the documentation for Quform 2.
This guide will show you how to populate a Hidden field with the name of the visitor’s country.
Step 1
Install and configure the WordPress plugin GeoIP Detection.
Step 2
Add a Hidden element to the form, then go to the settings for it and enable the option Dynamic default value then enter the Parameter name country
.
Step 3
Add the following code to the WordPress theme functions.php file (or create a plugin for it).
1 2 3 4 5 6 7 8 9 10 | function my_get_ip_country($value) { if (function_exists('geoip_detect2_get_info_from_current_ip')) { $record = geoip_detect2_get_info_from_current_ip(); $value = $record->country->name; } return $value; } add_filter('iphorm_element_value_country', 'my_get_ip_country'); |
function my_get_ip_country($value) { if (function_exists('geoip_detect2_get_info_from_current_ip')) { $record = geoip_detect2_get_info_from_current_ip(); $value = $record->country->name; } return $value; } add_filter('iphorm_element_value_country', 'my_get_ip_country');