Jump to content

Logout button


tooth-paste
 Share

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>

/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'.

Link to comment
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:

 

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