I wanted to delete an admin user programmatically, I have only FTP access.

  • when faced with issues like this, try to simulate the actions in the admin controller. If you take a look in Mage_Adminhtml_Permissions_UserController::deleteAction() you will find a code similar to what @SanderMangel posted as an answer. – Marius Oct 2 '13 at 7:09
  • While trying to delete an admin user, just be careful to not delete admin user id 0. – Fiasco Labs Oct 3 '13 at 2:51
  • Hey Nived, can you post the error you've received on the BE? – Sander Mangel Oct 7 '13 at 8:36

Although untested it stands to reason that you can use the normal Magento flow like with all models

Mage::getModel('admin/user')->load('user id')->delete();

But again, I didn't test it.

  • I tried the above code, not working, now I am not able to access admin, getting an error. – Nived Oct 2 '13 at 7:32
  • 1
    Please update your answer with the error thrown and also explain how you executed this code. – Sander Mangel Oct 2 '13 at 7:33
  • Confirmed, this method works. My code: $model = Mage::getModel('admin/user'); $user = $model->loadByUsername($username); $user->delete(); – Pronto Aug 25 '14 at 9:09

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.