Jump to content

User record won't delete


Gazley
 Share

Recommended Posts

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...