Execute a plugin in index.php

I want to run a plugin that I created in the “index.php” How I can do?

Is it running only once on login, or does it run every time you visit the dashboard, etc?

No running never, I want to run when he entered the “index.php”

Well, everything in Piwik is run from index.php, so that’s why I’m asking, when do you want the script in your plugin to run? Your plugin will need to extend the class of another plugin, such as login if you want it to run once they’re logged in, so once you settle on when you want to run it, you can then find the class you need to work on.

But for example the plugin “login” is running when you get in “index.php” I want that instead of running the “login” mine run.

1-Run it when a user enters the “index.php”.

To do this, you can in your plugin create a method getListHooksRegistered, and you can hook your plugin on the event Request.dispatch

Defined in Piwik/FrontController in line 488

Triggered directly before controller actions are dispatched. This event can be used to modify the parameters passed to one or more controller actions and can be used to change the controller action being dispatched to.


Thank you Matt, but i have another problem now.

Now I have this code in me plugin.

public function getListHooksRegistered( )
$hooks = array(
‘Request.dispatch’ => ‘LlamarController’
return $hooks;

function LlamarController(&$module, &$action, &$parameters) {
$module = ‘LoginCookie’;
$action = ‘Ejecucion’;
$parameters = array( );

And this in me controller.

public function Ejecucion( ) {
LoginCookie:: DoCookieTDP( );
LoginCookie:: checkCookieTDP( );

In my function “checkCookieTDP” I do a redirect to “index.php” if a particular cookie created in the domain, but there it redirects to another page outside the domain.

If the cookie exists should redirect to index.php and that’s it, but goes into a loop.

I think the problem is that every time you run the dispatch entering index.php, Is there any way that ejcute only once?

no matter, I’ve solved all alone