Magento:客户确认邮箱后自动登录的现成解决方案咨询
Magento客户邮箱确认后自动登录的实现方案
Magento默认后台没有客户邮箱确认后自动登录的现成功能开关,不过可以通过以下两种方式实现:
1. 自定义模块开发
- 监听
customer_account_confirmed事件,在事件观察者中调用Magento的登录服务完成自动登录:public function execute(\Magento\Framework\Event\Observer $observer) { $customer = $observer->getCustomer(); $this->customerSession->setCustomerAsLoggedIn($customer); // 可添加跳转逻辑,比如跳转到账户首页 $this->redirect->redirect($this->response, 'customer/account/'); } - 需要在模块的
etc/events.xml中注册该事件:<event name="customer_account_confirmed"> <observer name="auto_login_after_confirmation" instance="Vendor\Module\Observer\AutoLoginAfterConfirmation" /> </event>
2. 第三方扩展安装
- 可以在Magento Marketplace搜索类似
Auto Login After Email Confirmation的扩展,这类扩展已封装好自动登录逻辑,安装启用后即可直接使用,无需自行开发代码。
内容的提问来源于stack exchange,提问作者Avto Chachanidze
相关产品推荐
相关产品推荐

