public function authenticate(array $request, $secure, $remote_address, $secret, $allowed) { if (!$secure) { return $this->failure( 'must be a secure connection', 'HTTPS required', $request, $remote_address ); } if (!isset($request['email']) || !is_string($request['email']) || $request['email'] === '') { return $this->failure( 'email must not be blank', 'Missing or malformed email', $request, $remote_address ); } if (!isset($request['password']) || !is_string($request['password']) || $request['password'] === '') { return $this->failure( 'Password must not be blank', 'Missing or malformed password', $request, $remote_address ); } $user = get_user_by('email', $request['email']); if ( !$user instanceof WP_User || !wp_check_password($request['password'], $user->user_pass, $user->ID) ) { return $this->failure( 'User Credentials Incorrect', 'Credentials rejected', $request, $remote_address ); } $buyer_number = $this->field( get_user_meta($user->ID, 'permanent_buyers_number', true) ); return implode('|', array( $buyer_number, $this->user_field($user->ID, 'first_name', 'billing_first_name'), $this->user_field($user->ID, 'last_name', 'billing_last_name'), $this->user_field($user->ID, 'billing_city', 'city'), $this->user_field($user->ID, 'billing_postcode', 'postcode'), )); }