Here is my code
customerregistersuceessobserver.php
<?php
namespace Webkul\Marketplace\Observer\Rewrite;
use Webkul\Marketplace\Observer\CustomerRegisterSuccessObserver;
use Magento\Framework\Event\ObserverInterface;
use Webkul\Marketplace\Model\ResourceModel\Seller\CollectionFactory;
class CustomerRewriteRegisterSuccessObserver extends CustomerRegisterSuccessObserver
{
/**
* @var ObjectManagerInterface
*/
protected $_objectManager;
/**
* @var CollectionFactory
*/
protected $_collectionFactory;
/**
* @var \Magento\Framework\Stdlib\DateTime\DateTime
*/
protected $_date;
/**
* @var \Magento\Store\Model\StoreManagerInterface
*/
protected $_storeManager;
/**
* @var \Magento\Framework\Message\ManagerInterface
*/
private $_messageManager;
/**
* @param \Magento\Framework\ObjectManagerInterface $objectManager
* @param \Magento\Framework\Stdlib\DateTime\DateTime $date
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Framework\Message\ManagerInterface $messageManager,
* @param CollectionFactory $collectionFactory
*/
public function __construct(
\Magento\Framework\ObjectManagerInterface $objectManager,
\Magento\Framework\Stdlib\DateTime\DateTime $date,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Framework\Message\ManagerInterface $messageManager,
CollectionFactory $collectionFactory
) {
$this->_objectManager = $objectManager;
$this->_storeManager = $storeManager;
$this->_messageManager = $messageManager;
$this->_collectionFactory = $collectionFactory;
$this->_date = $date;
}
/**
* customer register event handler.
*
* @param \Magento\Framework\Event\Observer $observer
*/
public function execute(\Magento\Framework\Event\Observer $observer)
{
$data = $observer['account_controller'];
try {
$paramData = $data->getRequest()->getParams();
if (!empty($paramData['is_seller']) && !empty($paramData['selling_categories']) && $paramData['is_seller'] == 1) {
$customer = $observer->getCustomer();
//~ $profileurlcount = $this->_objectManager->create(
//~ 'Webkul\Marketplace\Model\Seller'
//~ )->getCollection();
//~ $profileurlcount->addFieldToFilter(
//~ 'selling_categories',
//~ $paramData['selling_categories']
//~ );
//~ if (!$profileurlcount->getSize()) {
$status = $this->_objectManager->get(
'Webkul\Marketplace\Helper\Data'
)->getIsPartnerApproval() ? 0 : 1;
$customerid = $customer->getId();
$model = $this->_objectManager->create(
'Webkul\Marketplace\Model\Seller'
);
$categories=implode(',',$paramData['selling_categories']);
$model->setData('is_seller', $status);
$model->setData('selling_categories',$categories);
$model->setData('seller_id', $customerid);
$model->setData('store_id', 0);
$model->setCreatedAt($this->_date->gmtDate());
$model->setUpdatedAt($this->_date->gmtDate());
if ($status == 0) {
$model->setAdminNotification(1);
}
$model->save();
$loginUrl = $this->_objectManager->create(
'Magento\Framework\UrlInterface'
)->getUrl("marketplace/account/dashboard");
$this->_objectManager->create(
'Magento\Customer\Model\Session'
)->setBeforeAuthUrl($loginUrl);
$this->_objectManager->create(
'Magento\Customer\Model\Session'
)->setAfterAuthUrl($loginUrl);
$helper = $this->_objectManager->get(
'Webkul\Marketplace\Helper\Data'
);
//~ if ($helper->getAutomaticUrlRewrite()) {
//~ $this->createSellerPublicUrls($paramData['profileurl']);
//~ }
$adminStoremail = $helper->getAdminEmailId();
$adminEmail = $adminStoremail ? $adminStoremail : $helper->getDefaultTransEmailId();
$adminUsername = 'Admin';
$senderInfo = [
'name' => $customer->getFirstName().' '.$customer->getLastName(),
'email' => $customer->getEmail(),
];
$receiverInfo = [
'name' => $adminUsername,
'email' => $adminEmail,
];
$emailTemplateVariables['myvar1'] = $customer->getFirstName().' '.
$customer->getLastName();
$emailTemplateVariables['myvar2'] = $this->_objectManager->get(
'Magento\Backend\Model\Url'
)->getUrl(
'customer/index/edit',
['id' => $customer->getId()]
);
$emailTemplateVariables['myvar3'] = 'Admin';
$this->_objectManager->create(
'Webkul\Marketplace\Helper\Email'
)->sendNewSellerRequest(
$emailTemplateVariables,
$senderInfo,
$receiverInfo
);
//~ } else {
//~ $this->_messageManager->addError(
//~ __('This Shop URL already Exists.')
//~ );
//~ }
}
} catch (\Exception $e) {
$this->_messageManager->addError($e->getMessage());
}
}
here I need to redirect the customer after register in magento 2 how i can set redirect (note: email verfication enabled)
how i can do this
now it redirects to the customer login page