WooCommerce 不会将密码发送给在 "My account" 页面上注册的客户

WooCommerce doesn't send the password to the customer registered on the "My account" page

虽然“创建帐户时自动生成帐户密码”选项被选中,但当用户在“我的帐户”页面上注册时,WooCommerce 不会发送给用户的密码,只有一个密码设置link“点击这里设置您的新密码。”。另一方面,当从结帐页面进行注册时,将发送密码。在“我的账户”页面注册后如何发送?

今天找了一整天解决这个问题的方法,不涉及编辑模板的方法,但我没有找到。

当客户通过“我的帐户”注册时,通知如图所示。

即使勾选了“创建账户时,自动生成账户密码”选项,由于WooCommerce 6.0.0自11月19日起进行了调整,现在新客户将收到一封没有自动生成密码的通知电子邮件,就像 5.9.0 一样,虽然它存在,但带有 link 邀请设置新密码(感谢 @7uc1f3r ).

最初,我想恢复在 WooCommerce 6.0.0 中所做的更改,但经过一段时间的分析,我认为新的更改在帐户安全方面是好的。但是现在,在注册和完成订单后,客户立即登录但没有可用的密码,因为它没有发送给他,即使它是创建的。而且因为不是每个人都定期阅读他们的电子邮件,所以我为新客户添加了一个额外的通知,例如在“收到订单”页面上,警告他们补充需要设置密码,这样他们以后就不会感到迷路发现由于缺少密码,他们无法访问自己的帐户。

/** 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' );
    }
} );