2016-09-21 92 views
0

如果客戶登錄wordpress,他會自動登錄到magento也 雖然客戶的電子郵件ID和密碼是註冊時在magento以及單詞按和在註冊的情況下正常工作,但是當我想登錄它不在magento中工作時。如果客戶登錄wordpress,他會自動登錄到magento

這裏附有影像

我已經嘗試 這個代碼 require_once( 「店/應用/ Mage.php」); umask(0);

 Mage::app("default"); 

     $session = Mage::getSingleton("customer/session"); 

     // Check if user is logged in 
     if($session->isLoggedIn()) 
     { 
     // Yes user is logged in 
      echo "Yes user is logged in"; 
     }else{ 
     $session = Mage::getSingleton('customer/session', array('name' =>   'frontend')); 
     $session->login("$email", "$password"); 
    $session->setCustomerAsLoggedIn($session->getCustomer()); 
     } 
+0

你有什麼錯誤嗎?或者用戶是否沒有登錄magento? – Slatyoo

+0

我沒有收到任何錯誤。 –

+0

所以..當你在wordpress註冊用戶登錄或註冊?請提供更多信息。你使用任何插件? – Slatyoo

回答

0

在登錄wordpress後,您可以強制使用郵件地址的用戶記錄狀態。

Mage::getSingleton('core/session', array('name' => 'frontend')); 
    $_customerExist = Mage::getModel('customer/customer') 
       ->getCollection() 
       ->addAttributeToSelect('*') 
       ->addAttributeToFilter('email', $_mail) 
       ->getFirstItem(); 
       $_customer = Mage::getModel('customer/customer') 
    ->load($_customerExist->getentity_id()); 

    if(!Mage::getSingleton('customer/session')->isLoggedIn()) { 
     $session = Mage::getSingleton('customer/session', array('name' => 'frontend')); 
     $session->setCustomer($_customer); 
     $session->setCustomerAsLoggedIn($_customer); 
    } 

如果你想用密碼來登錄你可以在這裏找到一個解決方案:

See here.

與您的版本去錯了請告訴我?看看你的日誌爲什麼登錄失敗。

+0

謝謝丹尼爾這不是我的問題,我想單次登錄和訪問WordPress和magento –