Gazley Posted February 9, 2014 Share Posted February 9, 2014 Hi, I have a "normal" page called "Customer". The data in this page is sufficient to create a "User" page. This User page uses the same name as the Customer page and a custom role is added. The User record is created perfectly and the User can log in without problem. When I delete the Customer, I also want to delete the User record. I have hooked the "trash" method in Pages. The method below gets called. Control gets to the line: wire('pages')->delete($user); and the User instance is the correct one. Despite this, when I go back to the Users list, the User record is still there. Any ideas why this record might is not being deleted? Thanks. private function customer_before_delete() { $page = $this->hooked_page; $users = wire('pages')->find("template=user, name=$page->name"); $user_cnt = count($users); if ($user_cnt === 1) { $user = $users->eq(0); wire('pages')->delete($user); } } Link to comment Share on other sites More sharing options...
Gazley Posted February 9, 2014 Author Share Posted February 9, 2014 No problem - this sorted it out nicely! http://processwire.com/talk/topic/4416-delete-user-when-page-is-deleted/?p=43345 Thanks Soma 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