4

Here is an work around for you. Inorder to change default association of customer you have to do some manual stuffs in database[Make sure you do backup of database before performing any database operations directly]. Go to database table customer_entity, find the customer entry by customer id. Change the website_id column to the new website where you want ...


3

Please try with below code. <?php public function __construct( \Magento\Framework\App\Action\Context $context, \Magento\Customer\Model\Session $customerSession ) { $this->redirect = $context->getRedirect(); $this->customerSession = $customerSession; } public function customerLogout() { $customerId = $this->...


2

You can use this below code in your controller file. protected $session; public function __construct( .... \Magento\Customer\Model\Session $session .... ){ .... $this->session = $session; .... } public function execute(){ $lastCustomerId = $this->session->getId(); $this->session->logout()->setBeforeAuthUrl($this->_redirect->...


2

Try with changing the session object <?php namespace YourCompanyName\YourModuleName\Block; class YourCustomBlock extends \Magento\Framework\View\Element\Template { protected $_customerSession; public function __construct( \Magento\Framework\View\Element\Template\Context $context, \Magento\Customer\Model\SessionFactory $...


2

Please try with below code... $customerSession = $objectManager->create("Magento\Customer\Model\Session"); echo $customerSession->getCustomerId(); I hope its work for you.


1

Depends on the required scope. Default behavior is that customers in different stores under same website can be shared. So you allocate website ID based on this. Customer can log in different stores using same credentials. If however customers need to work on different stores in different websites you must create new customer records.


1

You can use "customer_delete_after" event in Magento 2.3. <event name="customer_delete_after"> <observer name="ddg_remove_contact" instance="Dotdigitalgroup\Email\Observer\Customer\RemoveContact"/> </event> This event is used in Magento's dotmailer module in the vendor. Below is the link for the event list in Magento 2. https://...


1

You can check this with class MyClass { protected $customerSession; public function __construct(\Magento\Customer\Model\Session $customerSession) { $this->customerSession = $customerSession; } public isCustomerLoggedIn() { return $this->_customerSession->isLoggedIn(); } }


1

You can do this by making this following Code in your .phtml file: <?php $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $customerSession = $objectManager->create("Magento\Customer\Model\Session"); $contractAddress = $block->getContractAddress(); if($customerSession->isLoggedIn()) { //Your Code }...


1

This should be the right code: $customerSession = $objectManager->create("Magento\Customer\Model\Session"); echo $customerSession->getCustomerId(); By using this great code it should work. Therefore, the customer ID will get returned to you.


1

You need to create even observer as below <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd"> <event name="customer_login"> <observer name="customer_login_observer" instance="<Your_packagename>\<...


1

The field "Associate to Website" is used to associate the customer created with a particular website or to the admin. 1) When user is created with Associate to website as "Admin" then the user will not be able to login in the frontend. For this the values of store_id and website_id stored in database are 0. 2) When user is created with Associate to website ...


1

There is a problem with this particular event Magento 2 origData null in customer_save_before You are going to have to use a different event or code a workaround.


1

You can simply destroy session to logout the customer. /** @var Magento\Customer\Model\Session; */ $session->destroy(); And than redirect page to login page. /** @var \Magento\Framework\Controller\Result\Redirect $result */ $result = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); $result->setUrl($this->url->getUrl('customer/...


1

Use Session destroy() method. It's worked for me perfectly use Magento\Customer\Model\Session; use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\Controller\ResultFactory; use Magento\Framework\Message\ManagerInterface; use Magento\Framework\Registry; use Magento\Framework\UrlInterface; class Controllername() { //const ...


1

Try this code public function __construct( \Magento\Framework\App\Action\Context $context, \Magento\Customer\Model\Session $customerSession ) { $this->redirect = $context->getRedirect(); $this->customerSession = $customerSession; } public function customerLogout() { $customerId = $this->customerSession->getId(); if($...


1

Check the value of $username $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $customerObj = $objectManager->create('Magento\Customer\Model\ResourceModel\Customer\Collection'); $customer = $customerObj->addAttributeToSelect('*') ->addAttributeToFilter('celular',$username) ->load(); echo $customer->...


1

Use getData() method to get email $customer = $observer->getEvent(); $email=$customer->getData('email'); Updated answer: $CustomerModel = $objectManager->create('Magento\Customer\Model\Customer'); $CustomerModel->loadByEmail($email); $userId = $CustomerModel->getId(); Note: Code Tested


1

https://community.magento.com/t5/Magento-2-x-Programming/Redirect-to-Account-Dashboard-During-Checkout-Funnel-Login/td-p/74271 set $response['redirectUrl'] = $this->url->getUrl('checkout/cart');


Only top voted, non community-wiki answers of a minimum length are eligible