Title: Problem Importing User
Last modified: May 12, 2021

---

# Problem Importing User

 *  Resolved [anjalistha](https://wordpress.org/support/users/anjalistha/)
 * (@anjalistha)
 * [5 years ago](https://wordpress.org/support/topic/problem-importing-user/)
 * Hi,
 * I am trying to bulk import users to the wordpress but I am facing some problems.
 * Scenario 1:
    New import csv – username: first.name email: [first@gmail.com](https://wordpress.org/support/topic/problem-importing-user/first@gmail.com?output_format=md).
 * import setting:
    update existing users : No update emails : No, but create a 
   new user with a prefix in the username
 * result
    – Update is success as there is no duplicate username or email.
 * Scenario 2:
 * csv:
    username email first_name last_name first.last [first@gmail.com](https://wordpress.org/support/topic/problem-importing-user/first@gmail.com?output_format=md)
   first last
 * import setting:
    Update existing users – No update emails – No, but create a 
   new user with a prefix in the username
 * Result: User with username “first.last” exists, we ignore it
 * That is expected result as username and email is same.
 * Scenario3:
    username: first.name email: [first.name@gmail.com](https://wordpress.org/support/topic/problem-importing-user/first.name@gmail.com?output_format=md)(
   different email)
 * Update existing users – No
    update emails – No, but create a new user with a 
   prefix in the username
 * Result: User with username “first.name” exists, we ignore it
 * In this case should the new user be created with prefix in the username? or the
   update existing users has to be yes?
 * scenario 4:
    username: first.name email: [first.name@gmail.com](https://wordpress.org/support/topic/problem-importing-user/first.name@gmail.com?output_format=md)(
   different email)
 * Update existing users – Yes
    update emails – No, but create a new user with a
   prefix in the username
 * result:
    Email has changed, new user created with username duplicated_username_122827
 * In this case, should the username be first.name1 as how the wordpress handles
   the duplicate username? Is there a way to have duplicate username with a prefix
   in the username instead of duplicated_username_122827?
 * Please let me know what I am doing wrong?
 * Thank you,
    Anjali

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Author [Javier Carazo](https://wordpress.org/support/users/carazo/)
 * (@carazo)
 * [5 years ago](https://wordpress.org/support/topic/problem-importing-user/#post-14437071)
 * [@anjalistha](https://wordpress.org/support/users/anjalistha/),
 * Scenario 3:
 * > In this case should the new user be created with prefix in the username? or
   > the update existing users has to be yes?
 * I had to study the code to answer you.
 * Yes you have to set the update to Yes to be able the process to enter in this
   part.
 * Scenario 4:
    We have a function that prepares the new user in order to avoid 
   collision with names.
 * We can prepare a hook if you want to override it. Would you like it? How it should
   be this hook?
 *     ```
       function get_random_unique_username( $prefix = '' ){
               do {
                   $rnd_str = sprintf("%06d", mt_rand(1, 999999));
               } while( username_exists( $prefix . $rnd_str ) );
   
               return $prefix . $rnd_str;
           }
       ```
   
 *  Thread Starter [anjalistha](https://wordpress.org/support/users/anjalistha/)
 * (@anjalistha)
 * [5 years ago](https://wordpress.org/support/topic/problem-importing-user/#post-14437444)
 * Hi Javier,
 * Yes that would be great.
 * Thank you so much for your prompt reply.
 * Regards,
    Anjali
 *  Plugin Author [Javier Carazo](https://wordpress.org/support/users/carazo/)
 * (@carazo)
 * [5 years ago](https://wordpress.org/support/topic/problem-importing-user/#post-14438053)
 * [@anjalistha](https://wordpress.org/support/users/anjalistha/),
 * How would you prepare the hook? Any suggestions?
 *  Thread Starter [anjalistha](https://wordpress.org/support/users/anjalistha/)
 * (@anjalistha)
 * [5 years ago](https://wordpress.org/support/topic/problem-importing-user/#post-14438256)
 * Hi Javier,
 * Sorry I don’t understand. Do I need to do something in the code to implement 
   it? I am not very good in programming that is why I was looking for plugin which
   can handle these without me having to change any codes.
 * Thank you,
    Anjali
 *  Plugin Author [Javier Carazo](https://wordpress.org/support/users/carazo/)
 * (@carazo)
 * [5 years ago](https://wordpress.org/support/topic/problem-importing-user/#post-14438272)
 * [@anjalistha](https://wordpress.org/support/users/anjalistha/),
 * Sorry I think you are confused:
    1) we cannot change the way we do it because
   this is a sure and formal way 2) I create a hook, a filter, in order you can 
   override with your code the standard way to do it 3) I need to know how do you
   want to filter these variables, so I asked you how would you use this filter

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Problem Importing User’ is closed to new replies.

 * ![](https://ps.w.org/import-users-from-csv-with-meta/assets/icon-256x256.png?
   rev=1174343)
 * [Import and export users and customers](https://wordpress.org/plugins/import-users-from-csv-with-meta/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/import-users-from-csv-with-meta/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/import-users-from-csv-with-meta/)
 * [Active Topics](https://wordpress.org/support/plugin/import-users-from-csv-with-meta/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/import-users-from-csv-with-meta/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/import-users-from-csv-with-meta/reviews/)

## Tags

 * [Import](https://wordpress.org/support/topic-tag/import/)

 * 5 replies
 * 2 participants
 * Last reply from: [Javier Carazo](https://wordpress.org/support/users/carazo/)
 * Last activity: [5 years ago](https://wordpress.org/support/topic/problem-importing-user/#post-14438272)
 * Status: resolved