Jump to content
Sign in to follow this  

Logout button

Recommended Posts

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>


wire()->addHookBefore("ProcessLogin::executeLogout", null, "setRedirect");

    function setRedirect(HookEvent $event) {

In the admin I can not find a page on '/admin/login/logout'.

Share this post

Link to post
Share on other sites

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:


    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 by kongondo
  • Like 2
  • Thanks 1

Share this post

Link to post
Share on other sites

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.


<?php namespace ProcessWire;


  • Like 4

Share this post

Link to post
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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...