Daniel
Daniel

Reputation: 716

Magento - Programatically retrieve and set admin users status

For a custom extension I'm building I need to be able to set and retrieve the status of an administrator user (not a customer) in Magento. I imagine you could achieve this like so;

$id; // ID of user stored here
$user = $mage->getadminuser($id); // store the user as an object or array in a variable with ID
$user->getStatus(); // return either true or false?
$user->setStatus(active or not active); // activate or deactivate the user

If anyone could provide me with the code to do this or documentation where I can find this easily? Thanks!

Upvotes: 0

Views: 378

Answers (1)

Marius
Marius

Reputation: 15216

$id = 5;
$admin = Mage::getModel('admin/user')->load($id);
if ($admin->getId()){
    $admin->setIsActive(1);//or 0
    $admin->save();
}

Upvotes: 2

Related Questions