Support » Fixing WordPress » How to import users from a CSV file

  • I want to import 500+ users from a CSV file….but there does not seem to be any way to do this. Has anyone accomplished this? It seems like something that would be useful to folks.

    Thank You

    – Ken

Viewing 7 replies - 1 through 7 (of 7 total)
  • I’m not aware of any wordpress functions to do that. Doesn’t mean there aren’t any… (maybe poke around

    A php wiz could probably womp something up to do it directly into the tables, I reckon.

    Yeah I looked around for something, but could not find anything…maybe this would be a good project for my first wp plugin.

    A CSV file is rather useless in defining a structure for it’s contents. Thus, you couldn’t come up with a single tool that could import ANY and all CSV files.

    If you did export this from an existing database, why not in the proper SQL format?


    Well if you are adventurous you could use something like That php script, csv2sql.php, will generate the SQL INSERT statements that you could copy and paste into the SQL query box in phpMyAdmin.

    To do this you should be familiar with the WordPress database structure, in particular, the “wp_users” and “wp_usermeta” tables.

    With the sample data below, I was able to generate the correct INSERT statements. I did have to change the two “explode” statements csv2sql.php, lines 39 and 61, to use “|” instead of “,” for the field separators due to the “wp_capabilities” row in “wp_usermeta”. I played with the password field and ended up using “password” and expect your users will need to have a new password sent to them. Note that if your database prefix is different that “wp_” you need to reflect that in the “wp_usermeta” rows “wp_capabilities” and “wp_user_level”. You will want to insure each “ID” and “user_login” is unique.

    Sample data used:

    3|peter|password|peter||http://|2005-12-10 12:19:12||0|peter



    Where it says:
    …to use “|” instead of “,”…

    should read:
    …to use “|” instead of “;”…

    Also, I assumed users would be assigned the subsciber role so you may need to change that as appropriate.

    Just a comment about passwords–this is the MySQL command that stores a password of carrots with a u ser:

    UPDATE wp_users SET user_pass = MD5( ‘carrots’ ) WHERE ID =3 LIMIT 1

    (the MD5 for carrots is 186a8b72fe696268c330f725f52be9ff)

    So don’t know what your existing password is like or if it could be used here. If you do know the MD5 passwords, that will be put in the INSERT statements by csv2sql.php if you have it in your CSV file.

    Having this capability would be most welcome!! I have a user group for 1,100-plus already in .CSV … would be a simple matter to rearrange the fields for import into WP using each user’s e-mail address as their login, and simply ship them their initial password. HOWEVER, the need to also set their user level high enough for them to administer their account is the bugaboo. That information is in the meta table. Any thoughts on how to make a second import into that table with the correct user-level (we intend to start them out as contributers, since we already know them).

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How to import users from a CSV file’ is closed to new replies.