Support » Plugin: Import Users from CSV » [Plugin: Import Users from CSV] re-importing to update a user

  • Resolved misterdavo


    I have a csv with a single user (a test). role= subscriber.
    He imports fine.
    Then I change the csv and make his role contributor
    Import the csv and get: “No user was successfully imported, please check the error log.”
    Shouldn’t I be able to re-import an existing user and have it just update the record?

    Also a side-note: When it says click to get the error log, it’s always empty.

    Thanks so much.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Ulrich Sossou


    Are you using Multisite? If yes, here is how to correctly set the user role:

    To update an existing user, you need to add a new column called ‘ID’ and add the user ID in that column.

    Ulrich, I am not using Multisite.

    I created a new column after the existing columns, called it ID, and then just put in some random numbers because I wouldn’t know what else to enter for a user’s ID. There is of course no field called ID in the WordPress User Profile form, so already this sounds odd to me. The csv says it imports fine, but the user is not added at all. If the user exists already it does not update their record. I feel like I’m missing something obvious here.

    Look at my csv“>

    Update: I installed a csv exporter. Dumped out my sample user and found the first column was ‘URL’ It showed my admin account as ‘1’ and the other user as ‘565’. So I changed the ID column in my csv to 565 and imported that user and now it imports fine and I can change the user’s ID. But… how could I ever know what a User’s ID is in the first place unless I do this very manual process each time? I’d be better off updating users one by one, by hand.

    My users are all stored in an external database, and ideally I’d like to SET their ID in the first place via the CSV import. OR… have the CSV importer NOT use the ID field as the key, as it seems to here, but instead use the Username field which I can be certain will never ever change.

    I hope I’m making myself clear.

    Plugin Author Ulrich Sossou


    – The ID cannot be set in the first place. The WordPress core functions don’t allow that and I chose not to bypass them in the plugin code.

    – Using the ID field only for updating the users was intentional, but I added a filter so that anyone can change that behaviour is needed, with little coding. The code below should do that:

    function example_filter_import_userdata( $userdata ) {
    	if ( ! empty( $userdata['user_login'] ) ) {
    		$user = get_userdatabylogin( $userdata['user_login'] );
    		$userdata['ID'] = $user->ID;
    	return $userdata;
    add_filter( 'is_iu_import_userdata', 'example_filter_import_userdata' );

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Plugin: Import Users from CSV] re-importing to update a user’ is closed to new replies.