Would you like to set a default flag on the Smart Phone field when GDPR is enabled? When using the Smart Phone form field, the default country flag will attempt to be set based on the user’s IP address. When the GDPR setting is enabled, this setting is blocked and therefore the flag would need to be set manually by your visitors.
Setting up the form
First, for the purpose of this tutorial, we’ll presume you have already enabled the WPForms GDPR setting. If you need further assistance with this, please review this documentation.
Once the setting for GDPR is enabled, it’s time to add a Smart Phone to your form.
Now that the field is added, you can now add your GDPR Agreement form field as well.
Adding the code snippet
Now it’s time to add the following code snippet to your site. If you need help adding code snippets to your site, please review this tutorial.
This code above will look for the options.initialCountry = ‘SZ’; and set the flag for that country code of 52.
If you need help finding the correct country code you want to set your flag to, please take a look at this page to find the correct number.
Now when the page loads, it will automatically set the flag on the field.
Would you like to also style the Smart Phone field a little differently as well? Take a look at our tutorial on How to Separate Dial Code From Smart Phone Form Field Dropdown.
Action Reference: wpforms_wp_footer
Q: Will this work on a form with Page Breaks?
A: If your form has the Page Break form fields, then you’ll want to also add this snippet as well.