How To Pre-Populate Country and State Drop Downs In Registration Forms

  • Brian
    Brian
    Newbie 1 points
    March 22, 2015 at 4:44 pm

    I can see how easily form fields can be made in the theme but what is the process to pre-populate the drop-down select lists with countries and states/provinces? I need those options (along with many others) to be mandatory when users sign-up for an account and also editable when they manage their profile.

    I am new to WP. What php files do I edit to dynamically populate those select lists in the registration and edit profile pages (I can do this with PHP if I knew where to hook into these processes. I need to pass the user’s current geo location country and state to pre-select the appropriate options.

    I assume that any DB fields I make in the theme are stored in the theme’s tables and not in the WP tables… so I need to know where to reference these and how to reference these $var->stateprov or some kind of short codes… just not sure how to reference this stuff and where to find it in the theme files..

    Thanks!


  • Josh
    Super Guru 13,875 points
    March 22, 2015 at 5:06 pm

    Hello Brian
    For countries use Database Key country,for states use Database Key state

  • Brian
    Brian
    Newbie 1 points
    March 24, 2015 at 4:22 am

    Ok, country turns the text field into a select… state has no effect on the text field… (these are the custom registration fields I am working with)

    Where are the values coming from (what tables) and what file is matching the dbkey with a lookup? Just trying to learn this stuff and not sure why state won’t work.

    Also how can I pass the visitor’s location to the function… so their state and country are selected?


  • Josh
    Super Guru 13,875 points
    March 24, 2015 at 1:26 pm

    1.The file is class_search.php located in framework >class
    2.I think this will require some customization

    This reply was awarded the best answer by the topic poster.
Viewing 4 posts - 1 through 4 (of 4 total)

New Business Themes for WordPress 2020

Start your new website today!

View Business Themes