Magento 2. Create customer account programmatically with no password and confirmation requiredRemove Required field on Customer Create AccountMagento 2 Customer update API using CURLMagento 2: How to override newsletter Subscriber modelCreate New Customer Account - Shop Required ErrorMagento 2 Add new field to Magento_User admin formMagento customer account edit form remove passwordMagento 2. Duplicate firstname, lastname, email inputs on customer account create frontendCan't create an account for customer or Login with email or password in frontendMagento2 Create Account with password Webapi not workingHow to make Dynamic URL for Browser and Mobile Application - for Customer Confirmation mail URL?
Primes in a Diamond
Game artist computer workstation set-up – is this overkill?
Changing stroke width vertically but not horizontally in Inkscape
Why would a military not separate its forces into different branches?
Reverse ColorFunction or ColorData
Which "exotic salt" can lower water's freezing point by –70 °C?
Is throwing dice a stochastic or a deterministic process?
Do quaternary sulfur dications exist?
Picking a theme as a discovery writer
Copper as an adjective to refer to something made of copper
What word describes the sound of an instrument based on the shape of the waveform of its sound?
How is trade in services conducted under the WTO in the absence of the Doha conclusion?
Hostile Divisor Numbers
GitLab account hacked and repo wiped
Can an Iranian citizen enter the USA on a Dutch passport?
What are the requirements for a river delta to form?
Can anyone identify this unknown 1988 PC card from The Palantir Corporation?
Referring to person by surname, keep or omit "von"?
Is there a reason why Turkey took the Balkan territories of the Ottoman Empire, instead of Greece or another of the Balkan states?
Is crescere the correct word meaning to to grow or cultivate?
Has the United States ever had a non-Christian President?
What's the 2-minute timer on mobile Deutsche Bahn tickets?
Huffman Code in C++
Which version of the Squat Nimbleness feat is correct?
Magento 2. Create customer account programmatically with no password and confirmation required
Remove Required field on Customer Create AccountMagento 2 Customer update API using CURLMagento 2: How to override newsletter Subscriber modelCreate New Customer Account - Shop Required ErrorMagento 2 Add new field to Magento_User admin formMagento customer account edit form remove passwordMagento 2. Duplicate firstname, lastname, email inputs on customer account create frontendCan't create an account for customer or Login with email or password in frontendMagento2 Create Account with password Webapi not workingHow to make Dynamic URL for Browser and Mobile Application - for Customer Confirmation mail URL?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
Context:
Account Confirmation is set to required from backend.
I'm creating a new customer account using MagentoCustomerModelAccountManagementFactory::createAccount()
method.
$email = "jiro@example.com";
$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.
EDIT
https://github.com/magento/magento2/issues/14492
magento2 customer-account bug create
add a comment |
Context:
Account Confirmation is set to required from backend.
I'm creating a new customer account using MagentoCustomerModelAccountManagementFactory::createAccount()
method.
$email = "jiro@example.com";
$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.
EDIT
https://github.com/magento/magento2/issues/14492
magento2 customer-account bug create
add a comment |
Context:
Account Confirmation is set to required from backend.
I'm creating a new customer account using MagentoCustomerModelAccountManagementFactory::createAccount()
method.
$email = "jiro@example.com";
$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.
EDIT
https://github.com/magento/magento2/issues/14492
magento2 customer-account bug create
Context:
Account Confirmation is set to required from backend.
I'm creating a new customer account using MagentoCustomerModelAccountManagementFactory::createAccount()
method.
$email = "jiro@example.com";
$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.
EDIT
https://github.com/magento/magento2/issues/14492
magento2 customer-account bug create
magento2 customer-account bug create
edited Nov 24 '18 at 14:18
sv3n
10.1k62557
10.1k62557
asked Sep 21 '17 at 15:46
vitoriodachefvitoriodachef
1,184422
1,184422
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Go to Stores -> Configuration -> Customer Configuration -> Create New Account Options
Now Set Require Emails Confirmation to Yes
Clear cache.
[Update]
Overwrite Magento/Customer/Model/AccountManagement.php class.
Modify following method
/**
* Send either confirmation or welcome email after an account creation
*
* @param CustomerInterface $customer
* @param string $redirectUrl
* @return void
*/
protected function sendEmailConfirmation(CustomerInterface $customer, $redirectUrl)
try
$hash = $this->customerRegistry->retrieveSecureData($customer->getId())->getPasswordHash();
$templateType = self::NEW_ACCOUNT_EMAIL_REGISTERED;
if ($this->isConfirmationRequired($customer) && $hash != '')
$templateType = self::NEW_ACCOUNT_EMAIL_CONFIRMATION;
elseif ($hash == '')
$templateType = self::NEW_ACCOUNT_EMAIL_REGISTERED_NO_PASSWORD;
$this->getEmailNotification()->newAccount($customer, $templateType, $redirectUrl, $customer->getStoreId());
catch (MailException $e)
// If we are not able to send a new account email, this should be ignored
$this->logger->critical($e);
In your case $hash is empty. So change that logic.
Please read question carefully. Specially this part 'Account Confirmation is set to required from backend.'
– vitoriodachef
Sep 21 '17 at 16:01
Check updated answer.
– Sohel Rana
Sep 21 '17 at 16:03
Overriding the logic of this method will not solve the problem. Sure a confirmation email will be sent but the confirmation token will be null as no confirmation token was generated.The general behavior will not change. Customers will still appear as confirmed even if they never confirm their account.
– vitoriodachef
Sep 21 '17 at 16:12
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f194186%2fmagento-2-create-customer-account-programmatically-with-no-password-and-confirm%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Go to Stores -> Configuration -> Customer Configuration -> Create New Account Options
Now Set Require Emails Confirmation to Yes
Clear cache.
[Update]
Overwrite Magento/Customer/Model/AccountManagement.php class.
Modify following method
/**
* Send either confirmation or welcome email after an account creation
*
* @param CustomerInterface $customer
* @param string $redirectUrl
* @return void
*/
protected function sendEmailConfirmation(CustomerInterface $customer, $redirectUrl)
try
$hash = $this->customerRegistry->retrieveSecureData($customer->getId())->getPasswordHash();
$templateType = self::NEW_ACCOUNT_EMAIL_REGISTERED;
if ($this->isConfirmationRequired($customer) && $hash != '')
$templateType = self::NEW_ACCOUNT_EMAIL_CONFIRMATION;
elseif ($hash == '')
$templateType = self::NEW_ACCOUNT_EMAIL_REGISTERED_NO_PASSWORD;
$this->getEmailNotification()->newAccount($customer, $templateType, $redirectUrl, $customer->getStoreId());
catch (MailException $e)
// If we are not able to send a new account email, this should be ignored
$this->logger->critical($e);
In your case $hash is empty. So change that logic.
Please read question carefully. Specially this part 'Account Confirmation is set to required from backend.'
– vitoriodachef
Sep 21 '17 at 16:01
Check updated answer.
– Sohel Rana
Sep 21 '17 at 16:03
Overriding the logic of this method will not solve the problem. Sure a confirmation email will be sent but the confirmation token will be null as no confirmation token was generated.The general behavior will not change. Customers will still appear as confirmed even if they never confirm their account.
– vitoriodachef
Sep 21 '17 at 16:12
add a comment |
Go to Stores -> Configuration -> Customer Configuration -> Create New Account Options
Now Set Require Emails Confirmation to Yes
Clear cache.
[Update]
Overwrite Magento/Customer/Model/AccountManagement.php class.
Modify following method
/**
* Send either confirmation or welcome email after an account creation
*
* @param CustomerInterface $customer
* @param string $redirectUrl
* @return void
*/
protected function sendEmailConfirmation(CustomerInterface $customer, $redirectUrl)
try
$hash = $this->customerRegistry->retrieveSecureData($customer->getId())->getPasswordHash();
$templateType = self::NEW_ACCOUNT_EMAIL_REGISTERED;
if ($this->isConfirmationRequired($customer) && $hash != '')
$templateType = self::NEW_ACCOUNT_EMAIL_CONFIRMATION;
elseif ($hash == '')
$templateType = self::NEW_ACCOUNT_EMAIL_REGISTERED_NO_PASSWORD;
$this->getEmailNotification()->newAccount($customer, $templateType, $redirectUrl, $customer->getStoreId());
catch (MailException $e)
// If we are not able to send a new account email, this should be ignored
$this->logger->critical($e);
In your case $hash is empty. So change that logic.
Please read question carefully. Specially this part 'Account Confirmation is set to required from backend.'
– vitoriodachef
Sep 21 '17 at 16:01
Check updated answer.
– Sohel Rana
Sep 21 '17 at 16:03
Overriding the logic of this method will not solve the problem. Sure a confirmation email will be sent but the confirmation token will be null as no confirmation token was generated.The general behavior will not change. Customers will still appear as confirmed even if they never confirm their account.
– vitoriodachef
Sep 21 '17 at 16:12
add a comment |
Go to Stores -> Configuration -> Customer Configuration -> Create New Account Options
Now Set Require Emails Confirmation to Yes
Clear cache.
[Update]
Overwrite Magento/Customer/Model/AccountManagement.php class.
Modify following method
/**
* Send either confirmation or welcome email after an account creation
*
* @param CustomerInterface $customer
* @param string $redirectUrl
* @return void
*/
protected function sendEmailConfirmation(CustomerInterface $customer, $redirectUrl)
try
$hash = $this->customerRegistry->retrieveSecureData($customer->getId())->getPasswordHash();
$templateType = self::NEW_ACCOUNT_EMAIL_REGISTERED;
if ($this->isConfirmationRequired($customer) && $hash != '')
$templateType = self::NEW_ACCOUNT_EMAIL_CONFIRMATION;
elseif ($hash == '')
$templateType = self::NEW_ACCOUNT_EMAIL_REGISTERED_NO_PASSWORD;
$this->getEmailNotification()->newAccount($customer, $templateType, $redirectUrl, $customer->getStoreId());
catch (MailException $e)
// If we are not able to send a new account email, this should be ignored
$this->logger->critical($e);
In your case $hash is empty. So change that logic.
Go to Stores -> Configuration -> Customer Configuration -> Create New Account Options
Now Set Require Emails Confirmation to Yes
Clear cache.
[Update]
Overwrite Magento/Customer/Model/AccountManagement.php class.
Modify following method
/**
* Send either confirmation or welcome email after an account creation
*
* @param CustomerInterface $customer
* @param string $redirectUrl
* @return void
*/
protected function sendEmailConfirmation(CustomerInterface $customer, $redirectUrl)
try
$hash = $this->customerRegistry->retrieveSecureData($customer->getId())->getPasswordHash();
$templateType = self::NEW_ACCOUNT_EMAIL_REGISTERED;
if ($this->isConfirmationRequired($customer) && $hash != '')
$templateType = self::NEW_ACCOUNT_EMAIL_CONFIRMATION;
elseif ($hash == '')
$templateType = self::NEW_ACCOUNT_EMAIL_REGISTERED_NO_PASSWORD;
$this->getEmailNotification()->newAccount($customer, $templateType, $redirectUrl, $customer->getStoreId());
catch (MailException $e)
// If we are not able to send a new account email, this should be ignored
$this->logger->critical($e);
In your case $hash is empty. So change that logic.
edited Sep 21 '17 at 16:03
answered Sep 21 '17 at 15:58
Sohel RanaSohel Rana
23.9k34461
23.9k34461
Please read question carefully. Specially this part 'Account Confirmation is set to required from backend.'
– vitoriodachef
Sep 21 '17 at 16:01
Check updated answer.
– Sohel Rana
Sep 21 '17 at 16:03
Overriding the logic of this method will not solve the problem. Sure a confirmation email will be sent but the confirmation token will be null as no confirmation token was generated.The general behavior will not change. Customers will still appear as confirmed even if they never confirm their account.
– vitoriodachef
Sep 21 '17 at 16:12
add a comment |
Please read question carefully. Specially this part 'Account Confirmation is set to required from backend.'
– vitoriodachef
Sep 21 '17 at 16:01
Check updated answer.
– Sohel Rana
Sep 21 '17 at 16:03
Overriding the logic of this method will not solve the problem. Sure a confirmation email will be sent but the confirmation token will be null as no confirmation token was generated.The general behavior will not change. Customers will still appear as confirmed even if they never confirm their account.
– vitoriodachef
Sep 21 '17 at 16:12
Please read question carefully. Specially this part 'Account Confirmation is set to required from backend.'
– vitoriodachef
Sep 21 '17 at 16:01
Please read question carefully. Specially this part 'Account Confirmation is set to required from backend.'
– vitoriodachef
Sep 21 '17 at 16:01
Check updated answer.
– Sohel Rana
Sep 21 '17 at 16:03
Check updated answer.
– Sohel Rana
Sep 21 '17 at 16:03
Overriding the logic of this method will not solve the problem. Sure a confirmation email will be sent but the confirmation token will be null as no confirmation token was generated.The general behavior will not change. Customers will still appear as confirmed even if they never confirm their account.
– vitoriodachef
Sep 21 '17 at 16:12
Overriding the logic of this method will not solve the problem. Sure a confirmation email will be sent but the confirmation token will be null as no confirmation token was generated.The general behavior will not change. Customers will still appear as confirmed even if they never confirm their account.
– vitoriodachef
Sep 21 '17 at 16:12
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f194186%2fmagento-2-create-customer-account-programmatically-with-no-password-and-confirm%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown