0

I know generally how to add custom fields to the user profile page. However, I need to add a custom select box to the profile page that is populated with all the schools in the state. (Our users will be teachers, and we need to be able to associate them with a school and a school system county.)

The school data is contained in a spreadsheet that includes the school name and county for every school in the state. Is there a way to somehow import this data into the select box?

All I can think to do is to create a Custom Post Type for "Schools" and import the school spreadsheet as posts. The school name would be the post title, and the other information would be custom fields for that post. Then I would need to pull all the post titles into the User Profile select box.

However it seems like overkill to have a CPT for this. Is there a better or easier way to import this data into a custom select box?

Another wrinkle is that this list will be updated every year, so we'll need to re-import the spreadsheet every year.

I appreciate any help to get me started. I'm thoroughly confused!

1
  • School table autofill and custom fill
    – Munna
    Commented Nov 16, 2020 at 12:21

1 Answer 1

0

You should import the schools as a table in the database, separate from the other WordPress tables. You can than write a function that selects and returns schools and eventually link it to the field via ajax using something like select2 or jquery autocomplete.

2
  • Thank you. Using this method, will the school that was selected from that select box now be part of the User meta for that user? So if I were to export the User List, the school and its county would now be associated with that User?
    – LBF
    Commented Jan 26, 2015 at 20:11
  • The value that is inputed by each user is stored as any other custom user meta, inside wp_usermeta. If you export users with their usermeta it will certainly be there. The select2 or autocomplete are just means to only allow them to input predefined (existing) values.
    – tao
    Commented Jan 26, 2015 at 20:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.