4

I'm importing new members using the Member Import Utility, but get errors for duplicate screen_name. These members won't be posting so screen name is not used and email is username.

I've added a condition in Validate.php and EE_Form_validation.php to stop the validation:

if (1 == 2 && strtolower($this->cur_screen_name) != strtolower($this->screen_name))

this works okay when a single member registers via front end form, but not when importing XML file.

so I then hacked tools_utilities.php, commenting out:

                            /*
                        case 'screen_name':
                            $this->validate->screen_name = $tag->value;
                            if ( ! in_array($tag->value, $s))
                            {
                                $s[] = $tag->value;
                            }
                            else
                            {
                                $this->errors[] = array(lang('duplicate_screen_name').$tag->value);
                            }
                            break;
                            */

Seems to work, but has anyone had other issues with this? it would be good to know before I import 10K members.

  • 1
    Maybe it'd be better to hack tools_utilities to generate a random screen name? Or just use the email address as screen name? – Rob Sanchez Mar 8 '13 at 17:22
  • 1
    I'm importing from a spreadsheet that has a mixed bag of members, can't see reason to auto generate, I could easily add these random names before import. I like your thinking if I was importing on a regular basis. – Samsull Mar 8 '13 at 17:35
  • 2
    I can't really see a reason skipping the duplicates check will cause a problem going forward. – Rob Sanchez Mar 8 '13 at 17:43
  • thanks Rob for your feedback - I imported 10K members without any problems. And it's a hack that won't cause any big issues if forgotten on future system updates. – Samsull Mar 8 '13 at 23:33
  • Or you could add an $i++ number onto the screenname for duplicates. – GDmac Apr 10 '13 at 5:43
1

I'm more inclined to follow Robs suggestion. I don't know if this would work (Need to test it), but maybe something along the lines of this:

case 'screen_name':
$this->validate->screen_name = $tag->value;
if ( ! in_array($tag->value, $s))
{
        $s[] = $tag->value;
}
else
{
    $emailUserName = $member->children['email']->value;
    if ( ! in_array($emailUserName, $s))
        {
            $s[] = $tag->$emailUserName;
        }
        else{
            $this->errors[] = array(lang('duplicate_screen_name').$tag->value);
        }
}
break;

instead of commenting it out completely... Just make a NOTE in your CP sidebar notes or something along the lines of when/where/why you made the change so you can trace back to issues that may come up. I would think that "forcing" the email as the username would be better than ignoring it though. Especially since you are using the email as username anyway.

Like I said, debug that write up though. ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.