Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Activating and Inactivating Customers - any ideas? 
 
lucian303
Member
 
Avatar
Total Posts:  74
Joined:  2008-03-03
 

I’d like to make it so that customers whose ‘is_active’ field is 0 cannot log into the site, but I’m not sure how to pull up the customer model. On the back end, I would also like to add the option under the customer menu to activate or deactivate a customer.

Here’s a bit of code I’m playing around with, but am having no luck getting anything to work. It always returns false. I’m not sure that I’m getting to the right database. This is in

Customer/Model/Entity/Customer.php. The function is called by the authenticate() function in the same class:

public function isActive(Mage_Customer_Model_Customer $customer$email)
    
{        
        $select 
$this->_getReadAdapter()->select()
            ->
from($this->getEntityTable(), array($this->getEntityIdField()))
            ->
where('email=?'$customer->getEmail());
        
//if ($customer->getSharingConfig()->isWebsiteScope()) {
        //    $select->where('website_id=?', (int) $customer->getWebsiteId());
        //}
        //if ($customer->getId()) {
        //    $select->where('entity_id=?', $customer->getId());
        //}
        
        //$select->where('is_active=?', 0);        
        
        
$cust $this->_getReadAdapter()->fetchAll($select);
        
$custActive $cust['is_active'];
        
//Mage::throwException(Mage::helper('customer')->__(var_dump($custActive)));
        
        
if ($custActive{
            
return true;
        
}

        
return false;
    
}

Any help would be greatly appreciated.

 
Magento Community Magento Community
Magento Community
Magento Community
 
chandra bhushan yadav
Jr. Member
 
Total Posts:  12
Joined:  2008-07-30
 

For providing an account approval system-
1. In Mage/Adminhtml/Block/Customer/Edit/Tab/Account.php
add following code

$newFieldset = $form->addFieldset(
‘is_active_fieldset’,
array(’legend’=>Mage::helper(’customer’)->__(’Approval Status Management’))
);
$field = $newFieldset->addField(’is_active’, ‘select’,
array(
‘label’ => Mage::helper(’customer’)->__(’Approve Status’),
‘name’ => ‘is_active’,
‘options’ => array(
0 => Mage::helper(’customer’)->__(’UnApproved’),
1 => Mage::helper(’customer’)->__(’Approved’)
),
)
);

2. In Mage/Customer/Model/Entity/Customer.php in the section where fields are specified
add this-

‘is_active’,

3.In Mage/Customer/Model/Entity/Setup.php
‘is_active’ => array(’type’=>’static’),

 
Magento Community Magento Community
Magento Community
Magento Community
 
Dhiraj Patra
Jr. Member
 
Avatar
Total Posts:  9
Joined:  2009-10-29
India
 

Newly added attributes not showing in front end at customer attribute_codes array.

I had to added that field in to the customer_entity table and then only all are effected.
Thanks.

 
Magento Community Magento Community
Magento Community
Magento Community
 
elfling
Enthusiast
 
Avatar
Total Posts:  901
Joined:  2008-10-21
 

Well, followed the instructions and disabled an account. However they are still able to log into their account.

Anything I’ve missed?

 
Magento Community Magento Community
Magento Community
Magento Community
 
sandipbiswas
Jr. Member
 
Total Posts:  1
Joined:  2011-05-02
 

app/code/core/mage/cusomer/model/entity/cosutomer.php

modfy the function

public function loadByEmail(Mage_Customer_Model_Customer $customer$email$testOnly false)
    
{
    
        $select 
$this->_getReadAdapter()->select()
            ->
from($this->getEntityTable(), array($this->getEntityIdField()))
            ->
where('email=?'$email);
            
//->where('email=:customer_email');
        
if ($customer->getSharingConfig()->isWebsiteScope()) {
            
if (!$customer->hasData('website_id')) {
                Mage
::throwException(Mage::helper('customer')->__('Customer website ID must be specified when using the website scope.'));
            
}
            $select
->where('website_id=?', (int)$customer->getWebsiteId());
             
$select->where('is_active=?'1);  /// add for active account
              //$select->where('group_id=?', 1);
        
}

        
if ($id $this->_getReadAdapter()->fetchOne($select, array('email' => $email))) {
           
            
            $this
->load($customer$id);
        
}
        
else 
        
//Mage::throwException(Mage::helper('customer')->__('You account under Approval process'));
            
$customer->setData(array());
        
}
        
return $this;
    
}
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top