Title: wp_login returns error
Last modified: August 18, 2016

---

# wp_login returns error

 *  Resolved [kalico](https://wordpress.org/support/users/kalico/)
 * (@kalico)
 * [18 years, 11 months ago](https://wordpress.org/support/topic/wp_login-returns-error/)
 * I put `<?php wp_login(); ?>` in my template header, and I am getting this error
   message:
 *     ```
       Warning: Missing argument 1 for wp_login() in /home/blueribb/public_html/wp-includes/pluggable.php on line 170
   
       Warning: Missing argument 2 for wp_login() in /home/blueribb/public_html/wp-includes/pluggable.php on line 170
       ```
   
 * Here is the function itself, starting at line 170:
 *     ```
       function wp_login($username, $password, $already_md5 = false) {
       	global $wpdb, $error;
   
       	if ( '' == $username )
       		return false;
   
       	if ( '' == $password ) {
       		$error = __('<strong>ERROR</strong>: The password field is empty.');
       		return false;
       	}
   
       	$login = get_userdatabylogin($username);
       	//$login = $wpdb->get_row("SELECT ID, user_login, user_pass FROM $wpdb->users WHERE user_login = '$username'");
   
       	if (!$login) {
       		$error = __('<strong>ERROR</strong>: Invalid username.');
       		return false;
       	} else {
       		// If the password is already_md5, it has been double hashed.
       		// Otherwise, it is plain text.
       		if ( ($already_md5 && md5($login->user_pass) == $password) || ($login->user_login == $username && $login->user_pass == md5($password)) ) {
       			return true;
       		} else {
       			$error = __('<strong>ERROR</strong>: Incorrect password.');
       			$pwd = '';
       			return false;
       		}
       	}
       }
       endif;
       ```
   
 * Any thoughts as to why I’m getting this error? I put the function call for wp_register
   right before that, and it comes out just fine.
 * Thx.

Viewing 1 replies (of 1 total)

 *  Thread Starter [kalico](https://wordpress.org/support/users/kalico/)
 * (@kalico)
 * [18 years, 11 months ago](https://wordpress.org/support/topic/wp_login-returns-error/#post-587405)
 * I discovered that `<?php wp_loginout(); ?>` worked just fine. Odd, since the 
   function “wp_login” is defined and works in the Kubrick theme, on the exact same
   blog…maybe something different about my theme??….but hey, it works now, so I’m
   good.
 * (And for the record, everything works lots better when you turn on “anyone can
   register” in Admin >> Options >> General. 😛 )
 * 🙂

Viewing 1 replies (of 1 total)

The topic ‘wp_login returns error’ is closed to new replies.

## Tags

 * [missing argument](https://wordpress.org/support/topic-tag/missing-argument/)
 * [pluggable.php](https://wordpress.org/support/topic-tag/pluggable-php/)
 * [wp_login](https://wordpress.org/support/topic-tag/wp_login/)

 * 1 reply
 * 1 participant
 * Last reply from: [kalico](https://wordpress.org/support/users/kalico/)
 * Last activity: [18 years, 11 months ago](https://wordpress.org/support/topic/wp_login-returns-error/#post-587405)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
