2

I've created a custom authentication plugin and it works well. The plugin is in the plugins folder plugins/authentication.

Now I face the problem, when I would like to login in my backend, then the plugin will be initiated and my login into the backend fails.

How can I make the plugin only working for my frontend or by using my component?

1 Answer 1

3

You can restrict the plugin so that it only gets initiated in the frontend only, by using:

$app = JFactory::getApplication();

if($app->isSite())
{
    // Your plugin code
}

or to initiate for a specific component

$jinput      = JFactory::getApplication()->input;
$component  = $jinput->get('option');

if($component == 'com_content')
{
    // Your plugin code
}

Change com_content to the component you wish to check for.

Hope this helps

3
  • The plugin is created along the advisory of docs.joomla.org/…. In the plugin, there is a function 'onUserAuthenticate' but I did also several functions in addition. I've used your first solution. I did this solution in every function of this plugin. Iam not sure, whether I did the most elegant implementation, but otherwise I came up with errors. Thx
    – Perino
    Jan 28, 2015 at 15:12
  • @Perino - oops, I just spotted a mistake in the 2nd code snippet which I've now updated
    – Lodder
    Jan 29, 2015 at 13:04
  • 1
    thx Lodder, no worry about that, I did the needed customizing on that :)
    – Perino
    Jan 29, 2015 at 13:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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