2

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.

2
  • you mean you'd like to be able to register admin users via the front-end? Commented Oct 11, 2013 at 5:59
  • yes bro. I want to create admin users from front side. Commented Oct 11, 2013 at 6:12

1 Answer 1

1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.