Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

GabMelo's avatar

Implement Wordpress Password Compare into Laravel Auth

I'm trying to do an authentication using Wordpress user table but aways I get unauthotized response. This response is because I'm not comparing passwords. The password from wp_users is hashed and the password from request it isn't.

I'm here to get some help on how to compare password with mikemclin/laravel-wp-password. I don't know where to put it.

Laravel version: 10

AuthController.php

 public function login()
    {
        $credentials = ['user_email' => request('email'), 'user_pass' => request('password')];

        if (! $token = auth()->attempt($credentials)) {
            return response()->json(['error' => 'Unauthorized'], 401);
        }

        return $this->respondWithToken($token);
    }
0 likes
3 replies
GabMelo's avatar

@martinbean, I have to use WpPassword::check function, but I don't know where to use it. Is something related to auth()->attempt() function, but I don't know exactly where.

Please or to participate in this conversation.