• Resolved agusgonzalezs

    (@agusgonzalezs)


    Hello, I would like to know if it is possible for the country prefix for the telephone number to be selected automatically when previously selecting the country of nationality? It’s to speed up the user’s filling out but they should also be able to change it if they wanted to.

    Thank you so much

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Zafer – WPMU DEV Support

    (@wpmudevsupport15)

    Hi @agusgonzalezs,

    I hope you are doing well today!

    We are checking your request with our SLS (Second Line Support) team if it is possible to provide a workaround or custom code to achieve this and will inform you accordingly.

    Thanks for the patience while we are looking into this.

    Kind regards,
    Zafer

    Plugin Support Zafer – WPMU DEV Support

    (@wpmudevsupport15)

    Hi again @agusgonzalezs,

    Please try the following code snippet as mu-plugin and please note that the code is written for Form ID 1197 and with two fields (Address and Phone fields) as address-1 with country option available only for Nationality field and phone-1 set to International validation for Phone field which you should change to suit your form.

    <?php
    add_action( 'wp_footer', 'wpmudev_country_code_selection', 9999 );
    function wpmudev_country_code_selection() {
    	global $post;
        if ( is_a( $post, 'WP_Post' ) && !has_shortcode( $post->post_content, 'forminator_form' ) ) {
            return;
        }
    	?>
    	<script type="text/javascript">
    	jQuery(document).ready(function($) {
    		setTimeout(function() {
    			$('.forminator-custom-form').trigger('after.load.forminator');
    		}, 100);
    		
    		$(document).on('after.load.forminator', function(event, form_id) {
    			if ( event.target.id == 'forminator-module-1197' ) { //Please change 1197 to your form's ID
    				$('#address-1-country select').on('select2:select', function(e) {  //Please use first select field ID
    					var select_val = $(e.currentTarget).val();
                        var country_code = $(e.currentTarget).find('option[value='+select_val+']').attr('data-country-code').toLowerCase();
                        $('#phone-1 input').intlTelInput("setCountry", country_code);
    				});
    			}
    		});
    	});
    	</script>
    	<?php
    }

    You can find more information below on how to use mu-plugins.
    https://wpmudev.com/docs/using-wordpress/installing-wordpress-plugins/#installing-mu-plugins
    and
    https://www.ads-software.com/support/article/must-use-plugins/

    If you encounter any issues or could not make it work for you, please share an export of the form with us, so that we can check further.

    You can find more info on how to export the form here : https://wpmudev.com/docs/wpmu-dev-plugins/forminator/#import-export

    After exporting, please share the code using a services such as https://pastebin.com or https://justpaste.it/ which is free to use.

    Please always make sure to use such service to share the code and don’t post the code here directly as it will most likely be unusable.

    Kind regards,
    Zafer

    Plugin Support Zafer – WPMU DEV Support

    (@wpmudevsupport15)

    Hi again @agusgonzalezs,

    We haven’t heard from you in a while, we will go ahead and mark this thread as resolved. If you have any additional questions or require further help, please let us know!

    Kind regards,
    Zafer

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Telephone country code’ is closed to new replies.