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;








3















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










share|improve this question






























    3















    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










    share|improve this question


























      3












      3








      3


      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










      share|improve this question
















      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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 24 '18 at 14:18









      sv3n

      10.1k62557




      10.1k62557










      asked Sep 21 '17 at 15:46









      vitoriodachefvitoriodachef

      1,184422




      1,184422




















          1 Answer
          1






          active

          oldest

          votes


















          0














          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.






          share|improve this answer

























          • 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











          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
          );



          );













          draft saved

          draft discarded


















          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









          0














          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.






          share|improve this answer

























          • 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















          0














          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.






          share|improve this answer

























          • 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













          0












          0








          0







          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.






          share|improve this answer















          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.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          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

















          • 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

















          draft saved

          draft discarded
















































          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.




          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

          Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

          Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?