Problem with multiple hooks


I created dynamically 2 pages (invite page and invoice page). After creating them i want to set the status of both to ‘listed’ like this:

$newcontact->changeStatus("listed"); // template invite (action 1)
$newinvoice->changeStatus("listed"); // template invoice (action 2)

Both pages are now ‘public’.
I have a hook (‘page.changeStatus:after’) for both templates like this:

'hooks' => [
  'page.changeStatus:after' => function ($newpage,$oldpage) {
      $template=$newpage->intendedTemplate() ;
      if($template == "invite"){
        // do something //this works
     if($template == "invoice"){
       // do something // this is not executed

Only the hook-action for the first changestatus is executed (action 1). In this case the hook action for the invite template. The hook foor the invoice (action 2) not. Somebody an idea why the second is not executed?


did you check that that the invoice template is correctly working? e.g. that the $template variable really has “invoice” … most of the time i found myself that something was not properly set up and the template was not registered correctly. then the $template variable always resulted in “default”…

otherwise at least the if statement should work.


Yes, both are working correctly. I tested them seperatly.
When i change the order of the actions, only the first is executed.

$newinvoice->changeStatus("listed"); // template invoice (action 2)
$newcontact->changeStatus("listed"); // template invite (action 1) 

here hook of action 2 is only executed.

Seems like the changeStatus:after hook is only triggered once! :thinking:


well, if you always create and set the status, you could do it without hooks…

$newPage = page()->createChild([
            'slug' => Str::random(10,'alpha'),
            'template' => 'template',
            'content' => array(
// content

the same applies to your second page., too.


Hi, yes, that’s the way i allready do it to change the status of a page.
But i need the hooks to create a PDF document for each template seperately. With the hooks i don’t have to write the code multiple times…


Sounds like a bug. Could you please create an issue to help us keep track:


@distantnative, i created an issue. Hopefully this can be fixed easily! Thanks

1 Like