tooth-paste Posted September 22, 2018 Posted September 22, 2018 I would like a logout button on the front-end. I found this thread, but can not get it to work. This is my button: <a href="/admin/login/logout">Uitloggen</a> /site/ready.php wire()->addHookBefore("ProcessLogin::executeLogout", null, "setRedirect"); function setRedirect(HookEvent $event) { $event->object->setLogoutURL(wire('pages')->get('/')->httpUrl); } In the admin I can not find a page on '/admin/login/logout'.
kongondo Posted September 22, 2018 Posted September 22, 2018 (edited) Maybe I am not reading this correctly, but why do you need a Hook? The code is from the default site profile that ships with ProcessWire: <?php if($user->isLoggedin()) { // if user is logged in, show a logout link echo "<a href='{$config->urls->admin}login/logout/'>" . sprintf(__('Logout (%s)'), $user->name) . "</a>"; } else { // if user not logged in, show a login link echo "<a href='{$config->urls->admin}'>" . __('Admin Login') . "</a>"; } ?> Or maybe you mean you want them to login from a page other than the admin page? Edited September 22, 2018 by kongondo 2 1
Jonathan Lahijani Posted September 23, 2018 Posted September 23, 2018 You could just create a template called logout.php (and a page called Logout using that template), and link them to that page to logout. /site/templates/logout.php: <?php namespace ProcessWire; $session->logout(); $session->redirect($pages->get("/")->url); 4
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