netcarver Posted August 14, 2020 Posted August 14, 2020 I'm sure this should be pretty easy on PW - but is it possible to delete a user when they logout? Essentially, I have a bunch of ephemeral users I use for testing, once I log out as that user, I want them to disappear from PW. I've tried hooking before/after Session::logoutSuccess, and also just processing the ?logout=1 directly in a template file. Not feeling particularly bright at the moment.
kongondo Posted August 14, 2020 Posted August 14, 2020 (edited) Works fine for me. In ready.php $this->addHookAfter('Session::logoutSuccess', function(HookEvent $event) { $user = $event->arguments(0); // here, your condition for getting transitory user if($user->id>1025){ // just to confirm wire('log')->save('logged_out',$user->name); // delete the user wire('users')->delete($user); } }); ProcessWire 3.0.159 Edited August 14, 2020 by kongondo 3
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