I mean, I think adding something like:
function sc_social_connect_process_login( $is_ajax = false, $link_account = false ) {
and later:
} elseif ( $link_account ) {
update_user_meta( get_current_user_id(), $sc_provider_identity_key, $sc_provider_identity );
$user_data = get_userdata( get_current_user_id() );
$user_login = $user_data->user_login;
} elseif ( $user_id = email_exists( $sc_email ) && !$link_account) { // User not found by provider identity, check by email
update_user_meta( $user_id, $sc_provider_identity_key, $sc_provider_identity );
$user_data = get_userdata( $user_id );
$user_login = $user_data->user_login;
Than it should be enough to just pass the $link_account = true to the function somehow, when clicked on the link account button (these might be the same as the sc login button, only with some class).
Not sure if that helps…:-)