9 Mar 2015 at 22:55 #1715
Hi – has anyone managed to import a user list from a CSV file? A large organisation would present a challenge to create each user in the staff directory manually.
I’ve looked at doing this programmatically with sql queries and have suceeded in creating the basic user information in the wp-users table. Where it falls down is when creating the extended information in wp-usermeta, the username is incorrect and the line manager is blank.
I’m aware there is a way to import CSV files into pods, but the trick would be to link this data to the wp-users table where the userID is defined.
Any help or ideas would be most welcome.
10 Mar 2015 at 23:14 #1717
Update: I’ve made some progress by using the plugin “CSV Importer for Pods” found here https://wordpress.org/plugins/csv-importer-for-pods/.
It will create users from the CSV file and will and populate fields in wp_metadata and also in wp_users. What is doesn’t do is populate the “first_name”, “last_name” and “description” meta keys in wp_metadata. This means that while the user can be displayed by department, any search by name will fail.
11 Mar 2015 at 11:01 #1718
We are using version 4/ACF and used the plugin “Import users from CSV with meta” to import our users and if I recall correctly the only data we couldn’t import was line manager.
11 Mar 2015 at 11:28 #1719
Thanks colshaw. So far I’ve used a similar plugin, “import users from csv”. I run this right after the pods csv importer with a modified csv. It will amend the user with the missing data. I need to test it a little more but it looks promising. The last issue I have is with the user’s forum role. This appears to be encoded in the wp_capabilities metakey in wp_usermeta. This can easily be updated with an sql query via php but I’d like to find a more user-friendly solution!
11 Mar 2015 at 11:42 #1720
The plugin I mentioned above sets the forum role per import so we imported a csv with our “subscribers” then the authors etc. As your hands on with the WP backend you will no doubt end up with a more versatile solution but we needed the plugin otherwise it was going to be a manual task or launch the intranet and ask everyone to just register.
11 Mar 2015 at 11:49 #1721
Cool. Maybe It will work out for me to substitute your user import plugin for mine.
I would be very interested to know the fields you used in the csv. How did you target the “forum role” field? I assume your import did not overwrite the wordpress role, but amend the forum role to it? They are stored in the same database key BTW.
11 Mar 2015 at 12:11 #1722
Sorry deanoldey I meant WP user role not forum role.
16 Mar 2015 at 01:15 #1734
I’ve uploaded a rough and ready importer plugin that I’ve used before, which you can adapt as necessary. There are 2 importers, a simple team importer to run first, and a user importer to run second which can tie into the teams.
This requires you to create 2 spreadsheets using columns as specified below, export each spreadsheet to a CSV file, open the CSV in a TEXT EDITOR, copy the rows and paste into the converter (found under Tools). Don’t leave a blank at the end of the pasted contents.
//  team name
//  parent name
//  first_name
//  last_name
//  Nickname
//  Team name
//  Email
//  Phone
//  Mobile
//  Working pattern
//  Job title
//  Role/bio
//  Line manager
//  Skills
//  More bio
20 Mar 2015 at 02:00 #1735
Hi Luke – thanks for the plugin upload.
I’ve imported the teams I need using the first plugin, with no parent defined for each.
They all appear correctly under Settings | Teams
However, the user importer throws the error – “Can’t find sub team xxx”.
I can see in the code that $tterm = get_page_by_title($team, OBJECT, ‘team’);
However, a quick check is_null($tterm) returns TRUE.
Any ideas or pointers as to why it is failing?
15 Apr 2015 at 16:38 #1751
Hi Dean – did you have any luck with this? Just wondering if it’s a simple case of a blank line at the end of the content that you pasted?
11 May 2015 at 13:55 #1765
Hi Luke – yes the team import worked fine but the user import did not. This could have something to do with the fact that I was using v3 of the theme with Pods. In the end, I wrote a PHP script to read in the CSV file and populate the sql tables, wp_user, wp_usermeta and wp_podsrel so that everything worked OK.
You must be logged in to reply to this topic.