如何从Magento的customer_register_success事件中获取用户ID?

时间:2017-06-22 08:40:07

标签: magento events

我的观察员正在收听 customer_register_success 事件。

当新用户注册新帐户时,我只获取会话ID而不是用户ID。如何同时获取会话ID和用户ID?

我检索有关已注册客户的信息的方式:

string is

2 个答案:

答案 0 :(得分:3)

您可以在Observer中获取新创建的客户对象,如下所示:

$qrystring = "SELECT * FROM country where "; 
if($usearchprofile)
  $qrystring .= " name like '%$usearchprofile%' ";     
 if($usearchnicename) {
 if($usearchprofile){
   $qrystring .= " OR nicename like '%$usearchnicename%' "; 
  }else{
   $qrystring .= "nicename like '%$usearchnicename%' "; 
 }
}
if($usearchiso3) {
 if($usearchprofile || $usearchnicename){
 $qrystring .= " OR iso3 like '%$usearchiso3%' ";
 }else{
 $qrystring .= " iso3 like '%$usearchiso3%' ";
}
}

答案 1 :(得分:0)

<?php

namespace Vendor\Module\Observer;

use Magento\Framework\Event\ObserverInterface;

class RegisterSuccess implements ObserverInterface
{
    public function execute(\Magento\Framework\Event\Observer $observer)
    {
        $customer = $observer->getEvent()->getCustomer();
        $customerID = $customer->getId();
        $customerEmail = $customer->getEmail();
        $customerName = $customer->getFirstName();
    }
}