Skip to:
Content
Pages
Categories
Search
Top
Bottom

Creating large dropdowns in profile admin


  • GRAQ
    Participant

    @graq

    It’s a big manual job to create drop downs for countries, zip codes, towns, postcodes (and so on). I have a spreadsheet/table with all the values in that I want to add to the dropdown option. Can anyone point me in the right direction for the admin functions I could call to do this programmatically?

    Many thanks!

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

  • ultimateuser
    Participant

    @ultimateuser

    @graq I had to do the same for a drop down field. First I created a dropdown with let say 5 options (so you will know where to enter the other values later on). I downloaded the table from my database and added the other values through excel. Once done, I uploaded the file again in my database. Worked for me.


    GRAQ
    Participant

    @graq

    @ultimateuser Do you mean write values directly into bp_xprofile_fields ?
    I wrote some dirty SQL to do just that.
    ` $insertsql = $wpdb->prepare(“INSERT INTO {$tablename} (group_id, parent_id, type, name, description, is_required, order_by, field_order, is_default_option, option_order ) VALUES (%d, %d, %s, %s, %s, %d, %s, %d, %d, %d )”, $group_id, $parent_id, $type, $region, ”, 0, ”, 0, 0, $option_order );`

    To be honest, I was hoping there would be a better way.


    ultimateuser
    Participant

    @ultimateuser

    @graq Yes into bp_xprofile_fields.


    GRAQ
    Participant

    @graq

    It has indeed worked a treat. Seems very possible for someone to extend this into a csv-style upload (as there once was, by the looks of my searching).

    I am vaguely interested in how ‘uploading a spreadsheet into a database’ works :)

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Creating large dropdowns in profile admin’ is closed to new replies.
Skip to toolbar