0

I'm trying to create a custom registration for the customer in the woocommerce registration page. Basically, I want the users to register with their their basic details, without their password. Once they do, I will be the one to generate their password for them in the wordpress dashboard. Is this possible? And how can I do this?

1
  • If you are using custom registration form then you can pass static password field in user_pass $userdata = array( 'user_login' => XXX, 'user_url' => XXX, 'user_pass' => STATIC_PWD ); $user_id = wp_insert_user( $userdata ) ;
    – Parth Shah
    Jul 8, 2019 at 10:30

1 Answer 1

0

Use this snippet to create user without password

$website = "http://example.com";
$userdata = array(
  'user_login'  =>  'login_name',
  'user_url'    =>  $website,
  'user_pass'   =>  NULL  // When creating an user, password is expected.
);   
$user_id = wp_insert_user( $userdata ) ;
//after this you can update user on this way 
update_user_meta( $user_id, 'some_meta_key', $meta_value );
or
//create user with random password 
$random_password = wp_generate_password( $length=12, $include_standard_special_chars=false );
$user_id = wp_create_user( $user_name, $random_password, $user_email );
//then update/add user information on this way
update_user_meta( $user_id, 'some_meta_key', $meta_value );
1
  • Hello, thank you for your answer. I was about to do this, but I found it easier to use the auto generate password option from woocommerce settings and modify the email that the customer got automatically by removing the option to send their password. Again, thank you.
    – kitmin
    Jul 10, 2019 at 5:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.