Skip to content

Commit

Permalink
Check wp_insert_user for WP_Error
Browse files Browse the repository at this point in the history
  • Loading branch information
krbvroc1 committed Feb 3, 2013
1 parent 3680be6 commit 5b80c94
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion classes/class-wc-checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -620,8 +620,9 @@ public function process_checkout() {

$this->customer_id = wp_insert_user( apply_filters( 'woocommerce_new_customer_data', $new_customer_data ) );

if ( ! $this->customer_id )
if ( is_wp_error( $this->customer_id ) ) {
throw new MyException( '<strong>' . __( 'ERROR', 'woocommerce' ) . '</strong>: ' . __( 'Couldn&#8217;t register you&hellip; please contact us if you continue to have problems.', 'woocommerce' ) );
}

// Set the global user object
$current_user = get_user_by ( 'id', $this->customer_id );
Expand Down
2 changes: 1 addition & 1 deletion woocommerce-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ function woocommerce_process_registration() {

$user_id = wp_insert_user( apply_filters( 'woocommerce_new_customer_data', $new_customer_data ) );

if ( ! $user_id ) {
if ( is_wp_error($user_id) ) {
$woocommerce->add_error( '<strong>' . __( 'ERROR', 'woocommerce' ) . '</strong>: ' . __( 'Couldn&#8217;t register you&hellip; please contact us if you continue to have problems.', 'woocommerce' ) );
return;
}
Expand Down

0 comments on commit 5b80c94

Please sign in to comment.