How can I delete a customer in magento by refering using its object from Mage::getModel("customer/customer") ?
I already researched in google and with the bad luck I found nothing.
If you want to delete the customer with some code that runs from the admin area, this should be enough:
$id = 5;//replace with desired id
//or
//$customer = Mage::getModel('customer/customer')->loadByEmail($email);
$customer = Mage::getModel('customer/customer')->load($id);
$customer->delete();
If you want to delete the customer from the frontend area you need to wrap the code above in this:
Mage::register('isSecureArea', true);
//code from above goes here
Mage::unregister('isSecureArea');
I find it out. customer is an EAV like products that can be deleted using delete() method.
Just flag the object to be deleteable using $customer->setIsDeleteable(true) because the customer model class which is Mage_Customer_Model_Customer implements Mage_Core_Model_Abstract which contains the delete() method
I used the following codes below
$customer->loadByEmail('test@test.com');
$customer->setIsDeleteable(true);
$customer->delete();
Get Customer By Id
$id = 5;//replace with desired id
$customer = Mage::getModel('customer/customer')->load($id);
Get Customer By Email
$customer = Mage::getModel('customer/customer')->setWebsiteId(0)->loadByEmail($email);
Delete Customer
$customer->delete();