0

User login after Admin approval in Magento 1.9

Admin need to approve the account before the users can browse the products and view the pricing for the products.

4
  • not clear your requiremnet Commented Sep 23, 2017 at 6:35
  • Admin need to approve the account before the users can browse the products and view the pricing for the products
    – SNS
    Commented Sep 23, 2017 at 6:41
  • you need prelogin before anybody access whole website? right? Commented Sep 23, 2017 at 6:42
  • yes.. but we use registration and that user approve by the admin then only that user login to the site ..(now in Magento "user registration and login " ) we need to admin approve option ?
    – SNS
    Commented Sep 23, 2017 at 6:46

4 Answers 4

2

You have two requirement :

First admin approval, for this use extension https://github.com/Vinai/customer-activation

And for second requirement to restrict user to login before browsing website, for this you have to create a custom module or can edit in existing custom module for this:

add event in config.xml :

...
<events>
    <controller_action_predispatch>
        <observers>
            <restrictcustomers_controller_action_predispatch>
                <class>Custom_Module_Model_Observer</class>
                <method>restrictCustomer</method>
            </restrictcustomers_controller_action_predispatch>
        </observers>
    </controller_action_predispatch>
</events>
...

In Model/Observer.php :

public function restrictCustomer(Varien_Event_Observer $observer)
{
    $action = strtolower(Mage::app()->getRequest()->getActionName());
    $controller = strtolower(Mage::app()->getRequest()->getControllerName());
    $openActions = array(
        'index',
        'create',
        'createpost',
        'login',
        'loginpost',
        'logoutsuccess',
        'forgotpassword',
        'forgotpasswordpost',
        'resetpassword',
        'resetpasswordpost',
        'confirm',
        'confirmation'
    );          

    if (($controller == 'customer_account' || $controller == 'account') && in_array($action, $openActions)) {
        return; //if in allowed actions do nothing.
    }

    if ($controller == 'index' && $action == 'loginpost') 
    {
        return; //if in allowed actions do nothing.
    }

    if(! Mage::helper('customer')->isLoggedIn()){
        Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl('customer/account/login'));
    }
    else
    {
        return;
    }
}
0

You can see this:

How to add a customer pre-approval module?

https://www.extensionhut.com/customer-approve-disapprove.html

http://www.magebright.com/magento-customer-approve-extension.html#

Hope this can help you.

1
  • ok. thx.. we try it..
    – SNS
    Commented Sep 23, 2017 at 6:49
0

By default, Customer approval functionality is not available in magento. You can use the community extension for customer approval functionality.

Here is one community extension available for this: https://github.com/Vinai/customer-activation

2
  • ok. thx.. we try it..
    – SNS
    Commented Sep 23, 2017 at 6:49
  • Fatal error: Call to a member function toOptionArray() on boolean in /home/xxxxx/public_html/xxxx/app/code/core/Mage/Adminhtml/Block/System/Config/Form.php on line 463 (error )
    – SNS
    Commented Sep 23, 2017 at 8:06
0

This functionality is not available with Magento by default. So you probably need to implement this using a module. Basically, what you need to do here is:

  1. Create a customer attribute status for the customer entity.
  2. Now disable users activity when the status is inactive. This can involve disable users from viewing the catalog, disable the user from doing checkout, etc.

Hence this is too broad to answer in a single answer. You can also look for some nice extension that does the same functionality. I recommend this extension.

I hope you can deal with this.

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.