3

I do a custom PHP page that allows member to validate their Joomla login credentials. Following is the code.

    $credentials = array(
        'username' => $username,
        'password' => $password);

    $options = array();

    $authenticate = JAuthentication::getInstance();
    $response = $authenticate->authenticate($credentials, $options);

Will this code obey the Joomla user plugin events. For example If I write a plugin that uses 'onUserAfterLogin' will the above code call the plugin hook?

5

No.

To trigger plugin events, you should use:

$credentials = array(
    'username' => $username,
    'password' => $password);

$options = array();

$app = JApplicationCms::getInstance('site');
$result = $app->login($credentials, $options); // boolean true, if login suceeded

But as you can guess, this will do real login. So user will be logged in. If you want user to still be logged out, just use below code after success from $result.

if($result){
    $app->logout();
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.