guy Posted January 20, 2022 Share Posted January 20, 2022 Is there a recommended way to detect when a page is saved via the API vs the admin site within a save hook? Such as: $this->pages->addHookAfter('savedPageOrField', $this, 'someMethod'); within someMethod I'm currently doing the following: $saveBtn = $input->post('submit_save'); if (!$saveBtn) return; // only reach the below when passed a submit_save POST param ... The above seems to work but I wasn't sure if this was a reliable way, or if something more fit for purpose exists? Link to comment Share on other sites More sharing options...
ryan Posted January 20, 2022 Share Posted January 20, 2022 @guy You could try this: if($this->wire()->process == 'ProcessPageEdit') { // save from page editor } If you want to capture other types of page editors, like ListerPro, User Profile, etc. you could do this: if(wireInstanceOf($this->wire()->process, 'WirePageEditor')) { // save from any page editing process } 5 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now