I tried to show a popup message when customer tried to login. I add some code in LoginPost.php like in code below but it's not work.

LoginPost.php :

try {
      echo "  <script type='text/javascript'>
              alert('adadasd'); //This code i tried to popup a message

      $customer = $this->customerAccountManagement->authenticate($jsonObject[0]->EMAILOWNER, $jsonObject[0]->PASSWORDOWNER);
      setcookie("Role", $jsonObject[0]->ROLE, time() + (86400 * 30), "/");
      if ($this->getCookieManager()->getCookie('mage-cache-sessid')) {
         $metadata = $this->getCookieMetadataFactory()->createCookieMetadata();
         $this->getCookieManager()->deleteCookie('mage-cache-sessid', $metadata);

How can i show a popup there? So the login will not continue before the customer click the popup message?

  • Customer tried to login means? do u want to show popup when customer enters login page? – Ranganathan Nov 3 '17 at 4:43
  • No, when customer login from login page, there will be a popup on the login process, so after the popup clicked, the login process will continue. – Edwin Widhiyanto Nov 3 '17 at 6:07
  • u need pop up with yes or no button right? – Ranganathan Nov 3 '17 at 6:12
  • Yes, can i add that popup on login process? – Edwin Widhiyanto Nov 3 '17 at 6:13
  • yes u can done this by javascript – Ranganathan Nov 3 '17 at 6:15

Use this js code in your custom.js

require([ 'jquery', 'jquery/ui'], function($){
         confirm('Do you want to continue the process?');
  • so the js should added in custom js? can i add it to the LoginPost.php? – Edwin Widhiyanto Nov 3 '17 at 7:36

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.