How to Delete Current Page Programatically
Permalink
Hi all
I am trying to delete the current page then navigate to another page:
I can see in the logs it's not getting the url slug because I see this:
Application admin Page "" at path "" Moved to trash
Any suggestions would be gratefully received please :)
Thanks
Dave
I am trying to delete the current page then navigate to another page:
$post = \Page::getCurrentPage(); $postHandle = $post->getCollectionHandle(); function trashPage() { $page = \Page::getByPath($postHandle); $page->moveToTrash(); } function navToIndex() { ob_start(); $url = '/members-1/members-forum/'; while (ob_get_status()) { ob_end_clean(); } header( "Location: $url" ); }
Viewing 15 lines of 17 lines. View entire code block.
I can see in the logs it's not getting the url slug because I see this:
Application admin Page "" at path "" Moved to trash
Any suggestions would be gratefully received please :)
Thanks
Dave