Skip to content

Commit

Permalink
don't create a new user if registration is disabled (fixes rodrigopri…
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigoprimo committed Jan 26, 2014
1 parent 339d3e0 commit bf2d1d4
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions social-connect.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,15 +214,27 @@ function sc_social_connect_process_login( $is_ajax = false ) {
$user_login = $user_data->user_login;

} else { // Create new user and associate provider identity
$user_login = sc_get_unique_username($user_login);

$userdata = array( 'user_login' => $user_login, 'user_email' => $sc_email, 'first_name' => $sc_first_name, 'last_name' => $sc_last_name, 'user_url' => $sc_profile_url, 'user_pass' => wp_generate_password() );

// Create a new user
$user_id = wp_insert_user( $userdata );

if ( $user_id && is_integer( $user_id ) )
update_user_meta( $user_id, $sc_provider_identity_key, $sc_provider_identity );
if ( get_option( 'users_can_register' ) ) {
$user_login = sc_get_unique_username($user_login);

$userdata = array( 'user_login' => $user_login, 'user_email' => $sc_email, 'first_name' => $sc_first_name, 'last_name' => $sc_last_name, 'user_url' => $sc_profile_url, 'user_pass' => wp_generate_password() );

// Create a new user
$user_id = wp_insert_user( $userdata );

if ( $user_id && is_integer( $user_id ) ) {
update_user_meta( $user_id, $sc_provider_identity_key, $sc_provider_identity );
}
} else {
add_filter( 'wp_login_errors', function ( $errors ) {
$errors->errors = array();
$errors->add( 'registration_disabled', __( '<strong>ERROR</strong>: Registration is disabled.', 'social-connect' ) );

return $errors;
});

return;
}
}

wp_set_auth_cookie( $user_id );
Expand Down

0 comments on commit bf2d1d4

Please sign in to comment.