• Resolved anjalistha

    (@anjalistha)


    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: [email protected].

    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 [email protected] 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: [email protected] (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: [email protected] (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

    (@carazo)

    @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

    (@anjalistha)

    Hi Javier,

    Yes that would be great.

    Thank you so much for your prompt reply.

    Regards,
    Anjali

    Plugin Author Javier Carazo

    (@carazo)

    @anjalistha,

    How would you prepare the hook? Any suggestions?

    Thread Starter anjalistha

    (@anjalistha)

    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

    (@carazo)

    @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.