WordPress.org

Ready to get started?Download WordPress

Forums

Import Users from CSV
[resolved] Questions (15 posts)

  1. raonip
    Member
    Posted 3 years ago #

    Hi,

    That's great plugin!

    How can I set the user role? whats the colunm name for that?

    How can I Update de User? Where do I specify the colunm to find for the update key?

    Thanks very much!

    http://wordpress.org/extend/plugins/import-users-from-csv/

  2. Ulrich Sossou
    Member
    Plugin Author

    Posted 3 years ago #

    How can I set the user role? whats the colunm name for that?

    The column name is 'role'. Just put the role name (e.g. administrator, editor, contributor, and so on)

    How can I Update de User? Where do I specify the colunm to find for the update key?

    The column name is 'ID'. Just put the ID of the existing user.

  3. raonip
    Member
    Posted 3 years ago #

    Hi! that's great!! and quick answer!!

    It is possible to Update the user by the user LOGIN?
    If the user login is already in WordPress the details is updated?

    If not, is there a way I could change in the plugin?

    Thanks very much!!!

  4. Ulrich Sossou
    Member
    Plugin Author

    Posted 3 years ago #

    It is possible to Update the user by the user LOGIN?
    If the user login is already in WordPress the details is updated?

    No, but I will definitely add that in the future version.

    If not, is there a way I could change in the plugin?

    Yes. Find all references of $userdata['ID'] in the plugin file import-users-from-csv.php and replace them by $userdata['user_login'].

  5. raonip
    Member
    Posted 3 years ago #

    Owwww!!! That's PERFECT!!!

    Thanks very very much!!!!

  6. Ulrich Sossou
    Member
    Plugin Author

    Posted 3 years ago #

    After some reflexion, I decided not to include that feature in the plugin.

    Here is a simple way to do that without modifying the plugin code: http://pubpoet.com/2011/05/28/update-users-import-users-csv/.

    Let me know if you have other questions or features requests.

  7. raonip
    Member
    Posted 3 years ago #

    Hi! Thanks very much for that!

    It is possible to have different header names in my CSV?
    If I change the names in the code below, it will work?

    $userdata_fields       = array(
    					'ID', 'user_login', 'user_pass',
    					'user_email', 'user_url', 'user_nicename',
    					'display_name', 'user_registered', 'first_name',
    					'last_name', 'nickname', 'description',
    					'rich_editing', 'comment_shortcuts', 'admin_color',
    					'use_ssl', 'show_admin_bar_front', 'show_admin_bar_admin',
    					'role'
    				);

    Sometimes is not possible to have the CSV exported with this header names....would be great if we could change the names, even inside the code.......do you think is possible?

    Thanks again!

  8. raonip
    Member
    Posted 3 years ago #

    hi, have a look at this plugin:
    http://wordpress.org/extend/plugins/csv-user-import/

    It has a code that maps each column name to the user data......

    I don't know how to code that....just change somethings in PHP......maybe can help!!

    Thanks again!!

  9. Ulrich Sossou
    Member
    Plugin Author

    Posted 3 years ago #

    Hi.

    I am not sure I understand what you want, the plugin you link to doesn't use column names but positions.

    Do you want to be able to use e.g. "First Name" instead of "first_name"?

    If yes, you can do something like:

    add_filter( 'is_iu_import_userdata', 'example_filter_import_userdata', 10, 2 );
    
    function example_filter_import_userdata( $userdata, $usermeta ) {
    	if ( ! empty( $usermeta['First Name'] ) ) {
    		$userdata['first_name'] = $usermeta['First Name'];
    	}
    
    	return $userdata;
    }
  10. raonip
    Member
    Posted 3 years ago #

    Hi, that's Exactly what I need!!!! Very nice!

    I have to put this code in my functions file, right?
    If I want to change many colunm names I just copy and paste this part changing the names?

    if ( ! empty( $usermeta['First Name'] ) ) {
    		$userdata['first_name'] = $usermeta['First Name'];
    	}

    I'm just confused.....I try to import a CSV other then your example and is not working.....
    Maybe is because I'm made the CSV in MAcC OS X Editor?
    Can I send you the file?
    The CSV needs to be with "," or can be ";"?
    Also needs to be enclosed by " "??

  11. raonip
    Member
    Posted 3 years ago #

    Hi!

    I have just tried and I could Import the CSV that I created in my Editor. Just have to turn UTF-8.

    I tried your code below in my functions file and is not working....should I put anywhere else?

    add_filter( 'is_iu_import_userdata', 'example_filter_import_userdata', 10, 2 );
    
    function example_filter_import_userdata( $userdata, $usermeta ) {
    	if ( ! empty( $usermeta['First Name'] ) ) {
    		$userdata['first_name'] = $usermeta['First Name'];
    	}
    
    	return $userdata;
    }

    I also changed in CSV file header from "first_name" to "First Name".....

    Any clue?
    Thanks again for all your support!

  12. Ulrich Sossou
    Member
    Plugin Author

    Posted 3 years ago #

    Strange. I just tried that and it works. Can you check again?

  13. bazonline
    Member
    Posted 2 years ago #

    The column name is 'ID'. Just put the ID of the existing user.

    Hi Ulric, when I use the ID header, nothing gets imported, when I use user_id as a header, it does import the users but creates a different user id number to the one I need.

    Can you advise? I have to match these users to a bunch of posts that need to be imported that have a "profileid" field that must match with the user id

  14. Ulrich Sossou
    Member
    Plugin Author

    Posted 2 years ago #

    @bazonline, try the latest version (0.3.1) . And next time, please open a new thread. Old ones are easily overlooked.

  15. bazonline
    Member
    Posted 2 years ago #

    Thanks Ulrich, will get latest version- and thanks for replying on Christmas day!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic