commit e786223d478f5de37d52339f6399a82bce4882a4 Author: himselfv Date: Wed Mar 20 15:49:51 2013 +0400 Fix: do not continue when wp_insert_user() returns error diff --git a/includes/services/wsl.authentication.php b/includes/services/wsl.authentication.php index ec5e86d..42e9840 100644 --- a/includes/services/wsl.authentication.php +++ b/includes/services/wsl.authentication.php @@ -495,6 +495,10 @@ function wsl_process_login_reauth() $user_email , // .. ) = wsl_process_login_create_wp_user( $provider, $hybridauth_user_profile, $request_user_login, $request_user_email ); + + //There was a bug when *_create_wp_user returned WP_Error, so just in case + if( !is_integer($user_id) ) + return wsl_render_notices_pages( _wsl__("Invalid user_id returned by create_wp_user.", 'wordpress-social-login') ); } // finally create a wp session for the user @@ -873,12 +877,13 @@ function wsl_process_login_create_wp_user( $provider, $hybridauth_user_profile, if( $user_id && is_integer( $user_id ) ){ update_user_meta( $user_id, $provider, $hybridauth_user_profile->identifier ); } - else if (is_wp_error($user_id)) { - echo $user_id->get_error_message(); - } - else{ - return wsl_render_notices_pages( _wsl__("An error occurred while creating a new user!", 'wordpress-social-login') ); - } + else { + // do not continue without user_id or we'll edit god knows what + if( is_wp_error($user_id) ) + return wsl_render_notices_pages( _wsl__("An error occurred while creating a new user! ".$user_id->get_error_message(), 'wordpress-social-login') ); + else + return wsl_render_notices_pages( _wsl__("An error occurred while creating a new user!", 'wordpress-social-login') ); + } // Send notifications if ( get_option( 'wsl_settings_users_notification' ) == 1 ){ @@ -899,6 +904,10 @@ function wsl_process_login_create_wp_user( $provider, $hybridauth_user_profile, function wsl_process_login_authenticate_wp_user( $user_id, $provider, $redirect_to, $adapter, $hybridauth_user_profile ) { + //There was a bug when this function received non-integer user_id and updated random users, let's be safe + if( !is_integer($user_id) ) + return wsl_render_notices_pages( _wsl__("Invalid user_id in login_authenticate_wp_user", 'wordpress-social-login') ); + // calculate user age $user_age = $hybridauth_user_profile->age;