Skip to content Skip to main menu Skip to utility menu

User import

Home Forums GovIntranetters User import

This topic contains 10 replies, has 3 voices, and was last updated by  deanodley 4 years, 5 months ago.

  • Author
  • #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.

  • #1717


    Update: I’ve made some progress by using the plugin “CSV Importer for Pods” found here
    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.

  • #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.

  • #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!

  • #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.

    Good luck!

  • #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.

  • #1722


    Sorry deanoldey I meant WP user role not forum role.

  • #1734

    Luke Oatham

    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.

    // [0] team name
    // [1] parent name

    // [0] first_name
    // [1] last_name
    // [2] Nickname
    // [3] Team name
    // [4] Email
    // [5] Phone
    // [6] Mobile
    // [7] Working pattern
    // [8] Job title
    // [9] Role/bio
    // [10] Line manager
    // [11] Skills
    // [12] More bio

  • #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?
    Thanks, Dean

  • #1751

    Luke Oatham

    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?

  • #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.
    Thanks, Dean

You must be logged in to reply to this topic.