Jump to content

How to distinguish if a page was saved via a hook or by pressing the save button


Juergen
 Share

Recommended Posts

Hello @ all,

only a simple question: Is it possible (and if how) to distinguish if a page was saved via fe a save ready hook or manually by pressing the save button?

I have the problem that a special hook function should only run if the save button was pressed by a human. In my case the schedule pages module triggers a hook to set a child page status to unpublished and saves the child page and this save process leads to start another hook which changes some values in the parent page.

I only want to run this hook for the parent page if the child page was saved by pressing the save button and not by saving via a hook.

if(Save button was pressed) {
// run the hook
} else {
// do not run the hook
}

Maybe someone has struggled with the same problem and can give me a hint how to deal with this?

Best regards

 

Link to comment
Share on other sites

Does this help?

$this->addHookBefore('ProcessPageEdit::processInput', function($e) {
    if (wire('input')->post('submit_save')) {
        $e->message("This page has been saved by pressing the 'Save' button.");
    }
});

 

  • Like 4
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...