Context:
Account Confirmation is set to required from backend.
I'm creating a new customer account using \Magento\Customer\Model\AccountManagementFactory::createAccount()
method.
$email = "[email protected]";
$firstName = "Jiro";
$lastName = "Ono";
$customer = $this->customerFactoryData->create();
$customer->setEmail($email);
$customer->setFirstname($firstName);
$customer->setLastname($lastName);
// Make sure we have a storeId to associate this customer with.
$storeId = $this->storeManager->getStore()->getId();
$customer->setStoreId($storeId);
// Associate website_id with customer
$websiteId = $this->storeManager->getStore($customer->getStoreId())->getWebsiteId();
$customer->setWebsiteId($websiteId);
$this->accountManagement->createAccount($customer);
Problem:
This successfully creates an user account. And send an email to the user to set their password. Problem is that I need confirmation on this client as well, but they are shown in grid as confirmed by default even if the user never sets is password or never opens mail or never enters the website.
I can't seem to find the logic that sets the client as unconfirmed. I suspect is a plugin or an observer.
Any tips or suggestions are highly appreciated. Thanks.