nabo Posted July 14, 2020 Share Posted July 14, 2020 Hello is there a way to hook a page save but only when I save it from page edit? And is there a way to prevent page save hook when I trash it? thanks Link to comment Share on other sites More sharing options...
MoritzLost Posted July 14, 2020 Share Posted July 14, 2020 Not sure if there is a hook that will exclude trashed pages directly, but you can very easily check status changes inside the Pages::saved hook, and abort the hook if the page is / was trashed. Use $page->statusPrevious to get the previous status, then you can compare it with the current status. See this hook in my TrelloWire module, which reacts to status changes. In this case I check both the current and previous status, because I'm only interested in the changes. Note that statusPrevious will be null if the status hasn't changed. If you only care about whether the page is currently in the trash, you can just use $page->isTrash(). 2 Link to comment Share on other sites More sharing options...
nabo Posted July 14, 2020 Author Share Posted July 14, 2020 Thanks @MoritzLost!!!! 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