Move panel page to other location when published

User fills form on UI and on submits it. New sub-page in Kirby panel is created (draft page).
Admin checks created page and confirms it by publishing it.
When its published - page is moved to some other place (to some sub-folder based on page type).

First that comes in mind via “changeSlug” - to change path, but how to trigger this function on moment of publishing? Any advice will be much appreciated.

You have to react on status change of the page, i.e. page.changeStatus:after, see

changeSlug() will only change the foldername, not move the page to a subfolder. You would have to use Dir::move() from the Toolkit.

Thank You @texnixe !

@texnixe Dir::move works perfectly - only thing that got message that “page does not exist”. How can I navigate panel to moved page?

Unfortunately, you can’t redirect from a hook. The only think you can do is throw an error message.

I’m wondering if it would be an option to handle the page moving in the changeStatus dialog instead of via the hook…