How to add first/last name in newsletter subscriber module in Magento1.9
>> First add two fields ( subscriber_firstname, subscriber_lastname) in newsletter_subscriber table and
app\design\frontend\THEME\default\template\newsletter\subscribe.phtml.
>> Now edit this page : app\code\core\Mage\Newsletter\controllers\SubscriberController.php
Here you'll find "public function newAction()"
Paste the below code after this following code:
$status = Mage::getModel('newsletter/subscriber')->subscribe($email); //line (63)
///////////////////////// First Name //////////////////////////////
if ($this->getRequest()->getPost('subscriber_firstname'))
{
$subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
$name = (string) $this->getRequest()->getPost('subscriber_firstname');
$subscriber->setSubscriberFirstname($name);
$subscriber->save();
}
////////////////////// END ///////////////////////////////////////
Do same for field Last Name....
>> The above code will effect your frontend. If you want to see the information from Admin too, you have to implement a little bit.
Go to this link : app\code\core\Mage\Adminhtml\Block\Newsletter\Subscriber\grid.php
Add this code :
//It will show the information to the admin on News Letter Subscriber Section.
$this->addColumn('subscriber_firstname', array(
'header' => Mage::helper('newsletter')->__('Subscriber First Name'),
'index' => 'subscriber_firstname',
'default' => '----'
));
>> First add two fields ( subscriber_firstname, subscriber_lastname) in newsletter_subscriber table and
app\design\frontend\THEME\default\template\newsletter\subscribe.phtml.
>> Now edit this page : app\code\core\Mage\Newsletter\controllers\SubscriberController.php
Here you'll find "public function newAction()"
Paste the below code after this following code:
$status = Mage::getModel('newsletter/subscriber')->subscribe($email); //line (63)
///////////////////////// First Name //////////////////////////////
if ($this->getRequest()->getPost('subscriber_firstname'))
{
$subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
$name = (string) $this->getRequest()->getPost('subscriber_firstname');
$subscriber->setSubscriberFirstname($name);
$subscriber->save();
}
////////////////////// END ///////////////////////////////////////
Do same for field Last Name....
>> The above code will effect your frontend. If you want to see the information from Admin too, you have to implement a little bit.
Go to this link : app\code\core\Mage\Adminhtml\Block\Newsletter\Subscriber\grid.php
Add this code :
//It will show the information to the admin on News Letter Subscriber Section.
$this->addColumn('subscriber_firstname', array(
'header' => Mage::helper('newsletter')->__('Subscriber First Name'),
'index' => 'subscriber_firstname',
'default' => '----'
));
No comments:
Post a Comment