简体   繁体   中英

Wordpress | Woocommerce custom registration form

I would like to ask whether it is possible to create the registration with the only code that is sent to the user's mail after form submitted, I'm not sure how to do properly.

for example : The user enters his email and the system will automatically send the generated password example: " 12345 " And this password i want use for all users

<?php
function wcs_filter_password_email( $args ) {
    $args['user_pass'] = $args['user_email'];
    return $args;
}
add_filter( 'woocommerce_new_customer_data', 'wcs_filter_password_email' );

I found this code but do not know if it would work as I want it Thank you very much for your help.

Your example will give the user email for password. you need:

<?php
function wcs_filter_password_email( $args ) {
  $args['user_pass'] = "12345";
  return $args;
}
add_filter( 'woocommerce_new_customer_data', 'wcs_filter_password_email' );
?>

Put it in your functions.php and it should work.
Don't forget to set the password to be auto generated from WooCommerce > Settings > Accounts otherwise the user will be asked to provide a password.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM