Skip to content

Instantly share code, notes, and snippets.

@jarkkolaine
jarkkolaine / authenticate_with_email.php
Created September 18, 2015 11:58
A simple code snippet for authenticating a user using email address
public function authenticate_with_email( $user, $email, $password ) {
if ( is_wp_error( $user ) ) {
// Already failed
return $user;
}
if( empty( $email ) || empty ( $password ) ) {
$error = new WP_Error();
if ( empty( $email ) ) {
$error->add( 'empty_username', __( '<strong>ERROR</strong>: Email field is empty.' ) );