skip to Main Content

Although the "When creating an account, automatically generate an account password" option is checked, when the user registers on the "My account" page the WooCommerce doesn’t send the password to the user, only a password setting link "Click here to set your new password.". On the other hand, when the registration is made from the checkout page, the password is sent. How can it be sent after on the "My Account" page registration as well?

Today I searched all day for a solution to this problem, one that does not involve editing templates, but I did not find one.

enter image description here

When the customer registers via "My account" the notification looks like in the picture.

2

Answers


  1. Chosen as BEST ANSWER

    Even if you have checked the "When creating an account, automatically generate an account password" option, due to an adjustment have been made since November 19th in WooCommerce 6.0.0, now the new customers will receive a notification email without the automatically generated password, as was up to 5.9.0, although it exists, but with a link inviting to set a new password (thanks @7uc1f3r for this info).

    Initially, I wanted to revert the changes made in WooCommerce 6.0.0, but after some time of analysis, I decided that the new changes are good in terms of account security. But now, immediately after registration and completion of the order, the customer is logged in but does not have a password available, because it was not sent to him, even if it was created. And because not everyone reads their emails regularly, I have added an additional notification for new customers, for example on the "Order Received" page, which warns them supplementary about the need to set a password, so they don't feel lost when later discovers that they do not have access to their account due to the lack of a password.

    /** Add a user meta when a new customer account is created **/
    add_action( 'woocommerce_created_customer', function( $customer_id ) {
        add_user_meta( $customer_id, '_is_new_user', 'yes' );
    } );
    
    /** Add a notice to the "Order received" page if is a new registered customer **/
    add_action( 'woocommerce_before_thankyou', function() {
        $current_user = wp_get_current_user();
    
        if( $current_user->ID > 0 && 'yes' === get_user_meta( $current_user->ID, '_is_new_user', true ) ) {
            wc_print_notice( $current_user->first_name . ', thank you for creating an account on <em>' . get_option('blogname'). '</em>. We sent you to <em>' . $current_user->user_email . '</em> an email with useful information about your account. Attention, if you can't find it, check in your spam folder. To better secure your account, we recommend that you set a new password and save it in a safe place.', 'success' );
    
            //delete the user meta added when the new customer account was created
            delete_user_meta( $current_user->ID, '_is_new_user' );
        }
    } );
    

  2. i also stuck on same but found a way to

    Send autogenerated password in email to customer on registration->go to the

     plugin/woocommerce/templates/emails/customer-new-account.php
    

    file:customer-new-account.php

    '<strong>' . esc_html( $user_pass ) . '</strong>'
    

    complete file will be like->

    <?php
    /**
     * Customer new account email
     *
     * This template can be overridden by copying it to yourtheme/woocommerce/emails/customer-new-account.php.
     *
     * HOWEVER, on occasion WooCommerce will need to update template files and you
     * (the theme developer) will need to copy the new files to your theme to
     * maintain compatibility. We try to do this as little as possible, but it does
     * happen. When this occurs the version of the template file will be bumped and
     * the readme will list any important changes.
     *
     * @see https://docs.woocommerce.com/document/template-structure/
     * @package WooCommerceTemplatesEmails
     * @version 6.0.0
     */
    
    defined( 'ABSPATH' ) || exit;
    
    do_action( 'woocommerce_email_header', $email_heading, $email ); ?>
    
    <?php /* translators: %s: Customer username */ ?>
    <p><?php printf( esc_html__( 'Hi %s,', 'woocommerce' ), esc_html( $user_login ) ); ?></p>
    <?php /* translators: %1$s: Site title, %2$s: Username, %3$s: My account link */ ?>
    <p><?php printf( esc_html__( 'Thanks for creating an account on %1$s. Your username is %2$s. with password %3$s You can access your account area to view orders, change your password, and more at: %4$s', 'woocommerce' ), esc_html( $blogname ), '<strong>' . esc_html( $user_login ) . '</strong>', '<strong>' . esc_html( $user_pass ) . '</strong>', make_clickable( esc_url( wc_get_page_permalink( 'myaccount' ) ) ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></p>
    <?php if ( 'yes' === get_option( 'woocommerce_registration_generate_password' ) && $password_generated && $set_password_url ) : ?>
        <?php // If the password has not been set by the user during the sign up process, send them a link to set a new password ?>
        <p><a href="<?php echo esc_attr( $set_password_url ); ?>"><?php printf( esc_html__( 'Click here to set your new password.', 'woocommerce' ) ); ?></a></p>
    <?php endif; ?>
    
    <?php
    /**
     * Show user-defined additional content - this is set in each email's settings.
     */
    if ( $additional_content ) {
        echo wp_kses_post( wpautop( wptexturize( $additional_content ) ) );
    }
    
    do_action( 'woocommerce_email_footer', $email );
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search