Default Country

This topic contains 3 replies, has 3 voices, and was last updated by  bruce 6 days, 3 hours ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #2174

    yasmine.noueihed
    Participant

    Hello,

    How can I set a default country to be selected from the dropdown list?

    #2175

    Hi,

    Thank you for contacting us. There is no direct option to set the default country. However you can use our hook system. For example:
    add_filter(‘erforms_13452_select-1551968842703_load’,’default_country’,10,2);
    function default_country($command,$form){
    $command[‘on’] = array(‘select-1551968842703’);
    $command[‘default_value’]= ‘US’;
    array_push($commands,$command);
    return $command;
    }

    In the above code, replace 13452 with your Form’s ID. “select-1551968842703” is the field name for country dropdown. You will have t replace with your field’s name. You can get your country field’s name by locating it in the preview mode (right click on the field and click on ‘inspect element’ option).

    add the above code within your theme’s functions.php. If you can share the URL of your Form, we can provide you exact code.

    #2189

    yasmine.noueihed
    Participant

    Thank you for the support.

    #5283

    bruce
    Participant

    I tried the following code snippet from above, switching out my form and field details (and replacing the bad ‘ with ‘):

    add_filter( ‘erforms_97716_select-1565804090700_load’,’default_country’,10,2);
    function default_country($command,$form){
    $command[‘on’] = array(‘select-1565804090700’);
    $command[‘default_value’]= ‘US’;
    array_push($commands,$command);
    return $command;
    }

    The code saved fine, but it still isn’t selecting my default country to US. Did I do something wrong in my update to your demo code?

    FYI: I can give you the URL, but is there a way I can do that privately, as this site is not live yet and I dont want it to be spidered?

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.