Would you like to use WPForms’ Smart Phone field’s IP auto-detection feature while keeping GDPR enabled? By default, enabling GDPR Enhancements disables IP address detection, which the Smart Phone field uses to determine country codes. This guide will show you how to maintain both functionalities.
Adding the Code Snippet
To enable IP auto-detection while keeping GDPR active, add this code to your site. If you’re not sure how to add custom code, please see our guide on how to add code snippets.
/*
* Hide the price from notifications
*
* @link https://wpforms.com/developers/how-to-enable-gdpr-without-removing-smart-phone-ip-auto-detection
*/
function wpf_wpforms_frontend_strings( $strings ) {
$strings[ 'gdpr' ] = false;
return $strings;
}
add_filter( 'wpforms_frontend_strings', 'wpf_wpforms_frontend_strings', 10, 1 );
This code snippet will keep GDPR settings enabled in your forms, allow the Smart Phone field to use IP detection for country codes, and apply to all forms using the Smart Phone field.
And that’s all you need to stay compliant with GDPR while also keeping the IP detection. Next, would you like to also restrict countries for a Smart Phone field as well? Take a look at our tutorial on How to Restrict Countries Inside Smart Phone Form Fields.