Just another WordPress.com weblog

if u want to give functionality to user to delete their own account ::

in  app\code\core\Mage\Customer\controllers\AccountController.php

add below action

public function deleteAction()
{
$customerId = $this->getRequest()->getParam(‘id’, false);
$customerUrl = Mage::getSingleton(‘customer/session’)->getCustomer();
$temp = explode(“,”,$customerUrl);
$cust_id = $temp[1];   // user id from session

/* remove this condition if you use userid from session directly */
if($customerId != $cust_id)
{
$this->_redirect(‘/index’);
}
else {
if($customerId){
$customer = Mage::getModel(‘customer/customer’)->load($customerId);
$customer->delete(); // delete customer
$this->_getSession()->logout()
->setBeforeAuthUrl(Mage::getUrl()); // for loging out user
}

$this->_redirect(‘/index’);
}
}

pass current user id in query string or u can also take it fron session

also change in app\code\core\Mage\Customer\Model\Customer.php

in this function

protected function _beforeDelete()
{
// $this->_protectFromNonAdmin();  // comment this line
return parent::_beforeDelete();
}

comment $this->_protectFromNonAdmin();

– Meghna Vora

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: