tags:

views:

44

answers:

1

Hi,

I am writing a script that automatically imports users into magento. Here is a code snippet:

$customer = Mage::getModel("customer/customer");
$customer->website_id = $websiteId; 
$customer->setStore($store);

$customer->loadByEmail($riga[10]);

echo "Importo ".$data[0]."\n";
echo "  email :".$data[10]."\n";

$customer->setTaxvat($data[7]);
$customer->lastname =    $lastname;
$customer->email =       $data[10]; 
$customer->password_hash = md5($data[0]);

$customer->save();

The problem is that the users are created as "not confirmed", while I would like them to be "confirmed".

I tried with:

$customer->setConfirmation('1');

before the save, but it didn't work. Does anybody know how to confirm the user?

Thanks!

+3  A: 

I think setConfirmation() is waiting for a confirmation key. Try passing null and I think it will work?

Just to clarify:

$customer->save();
$customer->setConfirmation(null);
$customer->save();

Should force confirmation.

melee
That made it. :-)I'd just like to highlight that when creating a customer it is important to save *before* and *after* setting the confirmation key, as melee pointed out.
fdierre