1

in pop up box, we are displaying login form. once user enter wrong email id or password, we are displaying message : Invalid login/pw , but once they enter correct details and click on login button, than user will be logged in.

but issue is pop up box will remain until we close the pop up manually with help of close button as in below image, but i want to hide the pop up box if login is successfull.

we are calling below function once login button clicked.

controllers

protected function _createProduct() 
 { 

   try { 
         if(isset($login) && (is_array($login) && !empty($login)) || ($login!="")){ 
         $session->login($login['username'], $login['password']); 
         $result['redirect'] = $this->_getRefererUrl() ? $this->_getRefererUrl() : Mage::getUrl('customer/account', array( 
         '_secure' => true 
          )); 
                $result['success']  = true; 

                $customerId         = Mage::getSingleton('customer/session')->getCustomerId(); 
         } 
         else{ 
          $customerId = ""; 
         } 

         if ($doSave) 
           $product->save();                             

        return $product;                   

         } 
       catch () {  }                                   
}

enter image description here

update

i called the javascript file once user credentials are correct as : Mage::app()->getLayout()->getBlock('head')->addJs('js/hide/here.js');

& in here.js file , i add the code to hide complete pop up using class as :

jQuery(".ajaxlogin-window").hide();

html

<div class="ajaxlogin-window" id="something">
<form>
// email id and password code
<button>Login</button>
</form>
  • after login just refresh the current page & welcome back – Qaisar Satti May 2 '17 at 12:55
  • i checked your idea and discussed with client, but for some reason we dont want to refresh.... – user52996 May 2 '17 at 13:19
  • you use ajax ? and which popup you are using ? is it fancybox ? – Minesh Patel May 3 '17 at 5:52
  • @MineshPatel yes we are using ajax and custom pop up.... – user52996 May 3 '17 at 5:54
  • jQuery(".ajaxlogin-window").hide() put this when you get success from ajax. it should work – Minesh Patel May 3 '17 at 5:57
1

You have to call a javascript after the customer' credentials are correct.

Use this code to add a java script from your controller.

Mage::app()->getLayout()->getBlock('head')->addJs('js/path/here.js');

Update

You need to check function whether the customer is successful logged in or not, if you are getting the logged in customer than trigger the function to Hide the popup. But if customer is not logged in keep the popup as it is by showing the message of invalid username/password

  • means is i need to write the code in here.js to hide pop up box – user52996 May 2 '17 at 13:04
  • Yes add your js code here to hide the popup . – Nirmal Raval May 2 '17 at 13:06
  • i aded your code : Mage::app()->getLayout()->getBlock('head')->addJs('js/hide/here.js'); after line $result['success'] = true; here.js : function hideWindow() { document.getElementById('something').style.display = 'none'; document.getElementById('ajaxlogin-mask').style.display = 'none'; } please correct me if i am wrong.... – user52996 May 2 '17 at 13:13
  • when i attached this code to login button, its hiding the pop up once we click on login button = > onclick hideWindow()` – user52996 May 2 '17 at 13:37
  • I have updated my answer please check that. – Nirmal Raval May 3 '17 at 6:43

Your Answer

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