title: Couldn't login after registration in WordPress
body: <p>I have a case that I am registering a user with <code>wp_insert_user()</code> and logging in with <code>wp_signon()</code>. Registration is successful but when I use <code>wp_signon()</code>, I get error:</p>
  
  <blockquote>
    <p>'Invalid username or password. Please try again!'.</p>
  </blockquote>
  
  <p>Here are my efforts, I couldn't find the issue.</p>
  
  <pre><code>function wp_create_user_my($username, $password, $email = '', $fname, $lname) {
      $first_name = wp_slash($fname);
      $last_name = wp_slash($lname);
      $user_login = wp_slash($username);
      $user_email = wp_slash($email);
      $user_pass = $password;
      $userdata = compact('user_login', 'user_email', 'user_pass','first_name','last_name');
      return wp_insert_user($userdata);
  }
  </code></pre>
  
  <p>Here is code of <code>signon()</code></p>
  
  <pre><code>$login_data['user_login'] = esc_attr($username);
  $login_data['user_password'] = esc_attr($new_password);
  $login_data['remember'] = true;
  $user_verify = wp_signon($login_data, false);
  </code></pre>