1

I have a custom field in customer registration form which I want to add the value of it into a session variable called passcode. So far I have no success, what am I doing wrong?

<input type="text" name="passcode" id="passcode" value="" title="<?php echo $this->__('Passcode') ?>" class="input-text required-entry" />

Here is my observer

public function customerRegisterSuccess(Varien_Event_Observer $observer) {
    $login = Mage::app()->getRequest()->getParams('passcode');
    $session = Mage::getSingleton('customer/session');
    $session->setPasscode($login);
}
2

you have to pass your field in login array

<input type="text" name="login[passcode]" id="passcode" value="" title="<?php echo $this->__('Passcode') ?>" class="input-text required-entry" />

in your observer

public function customerRegisterSuccess(Varien_Event_Observer $observer) {
    $login = Mage::app()->getRequest()->getPost('login');
    $session = Mage::getSingleton('customer/session');
    $session->setPasscode($login['passcode']);
}
0

Change getParams() to getParam():

public function customerRegisterSuccess(Varien_Event_Observer $observer) {
    $login = Mage::app()->getRequest()->getParam('passcode');
    $session = Mage::getSingleton('customer/session');
    $session->setPasscode($login);
}
  • I have already tried that but it didn't work @SeStro – tufanayd Dec 7 '15 at 23:41
  • Check if anything is assigned to $login: "Mage::log($login, null, 'test.log', true);" – SeStro Dec 8 '15 at 5:21
0

Try this

$postData = Mage::app()->getRequest()->getPost();
print_r($postData['passcode']);

OR

Mage::app()->getFrontController()->getRequest()->getParams();
Mage::app()->getFrontController()->getRequest()->getParam('passcode');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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