In System->Permissions->Users from Admin Side, the Administrator can create User account for users and assign role. But I want to create a system in Store front to allow users to create account using registration, then the account should be activated by Store Admin. How to create registration page for Users in Store front side ? Thanks in advance.
1 Answer
Implement a Controller: http://blog.baobaz.com/en/blog/magento-module-create-your-own-controller.
Config:
<config>
...
<frontend>
<routers>
<arithmetic>
<use>standard</use>
<args>
<module>Baobaz_Arithmetic</module>
<frontName>arithmetic</frontName>
</args>
</arithmetic>
</routers>
</frontend>
</config>
Class:
class Baobaz_Arithmetic_IntegerController extends Mage_Core_Controller_Front_Action
{
public function multiplyAction(){
// save admin user
}
}
Then create an admin user inside your controller or implement your own model/helper:
// http://santoshyadavcse.wordpress.com/2013/02/04/magento-create-admin-user-programmatically/
try {
$user = Mage::getModel(‘admin/user’)
->setData(array(
‘username’ => ‘admin1′,
‘firstname’ => ‘Admin’,
‘lastname’ => ‘Admin’,
‘email’ => ‘[email protected]’,
‘password’ =>’admin123′,
‘is_active’ => 0 // THIS IS IMPORTANT
))->save();
} catch (Exception $e) {
echo $e->getMessage();
exit;
}
//Assign Role Id
try {
$user->setRoleIds(array(1)) //Administrator role id is 1 ,Here you can assign other roles ids
->setRoleUserId($user->getUserId())
->saveRelations();
} catch (Exception $e) {
echo $e->getMessage();
exit;
}
It is important, that you define your own role. If you don't do that, every user is admin. I don't think this is the plan.