How to assign an order number as a login password for store users? (WooCommerce)

41 Views Asked by At

Good afternoon. I need to change the login method for my Woocommerce store clients.

I’m using WooCommerce to book rooms. Is it possible to automatically create a customer account based on one order? I need the password to match the order number.

I’d like it to work like this:

After paying for the service, the client will receive his order number, for example “1234567”.

After paying for the order, a new account should automatically appear, which requires the customer’s email address and order number (“1234567”) to log in.

To cancel an order or change (modify a reservation), Client will log into his account using his email address as his username and his order number as his password – “1234567”.

This account will only be used for one order. To repeat a new order, a new account must be automatically created, the password of which will be the number of this new order.

(I need all this for simplified booking editing)

I would like to make these changes using function.php

I need these 3 features:

  1. I need to force new accounts to be created, even if an account with the same email address already exists, since the reference point for creating an account will be the new order number.

  2. Email address as his username

  3. Order number as his password

I would be glad to receive any help in this matter.

To replace the password with the order number, I tried this code, but unfortunately it doesn't work.

add_filter( 'pre_user_password' , 'woocommerce_new_order' );
function woocommerce_new_order( $user_password ) {
foreach($user_password as $order_id) {
$user_password = $_POST['password'];
    }
return $user_password;
  }
0

There are 0 best solutions below