File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -99,8 +99,15 @@ public static function mutate_and_get_payload() {
9999 if ( empty ( $ input ['email ' ] ) ) {
100100 throw new UserError ( __ ( 'Please provide a valid email address. ' , 'wp-graphql-woocommerce ' ) );
101101 }
102- if ( empty ( $ input ['password ' ] ) ) {
103- throw new UserError ( __ ( 'Please enter an account password. ' , 'wp-graphql-woocommerce ' ) );
102+
103+ // Validate password input.
104+ if ( 'no ' === get_option ( 'woocommerce_registration_generate_password ' ) && empty ( $ input ['password ' ] ) ) {
105+ throw new UserError (
106+ __ (
107+ 'A password was not provided and WooCommerce does not automatically generate one for you. ' ,
108+ 'wp-graphql-woocommerce '
109+ )
110+ );
104111 }
105112
106113 // Map all of the args from GQL to WP friendly.
@@ -110,7 +117,7 @@ public static function mutate_and_get_payload() {
110117 $ user_id = wc_create_new_customer (
111118 $ user_args ['user_email ' ],
112119 $ user_args ['user_login ' ],
113- $ user_args ['user_pass ' ],
120+ isset ( $ user_args ['user_pass ' ]) ? $ user_args [ ' user_pass ' ] : '' ,
114121 $ user_args
115122 );
116123
You can’t perform that action at this time.
0 commit comments