1

Is it possible to stay on the same page after logging out from the frontend, assuming that guests can still view that page?

By default, when logging out we are redirected to the homepage or some specific page set with postLogoutRedirect config setting.

3

Yep, postLogoutRedirect can be set to a function instead of a static value. So for example, in your template you can generate a hidden field in your logout form (or append a querystring parameter to the logout URL) that contains the path of the current page. Then set this in your general.php:

'postLogoutRedirect' => function($siteHandle) {
  return Craft::$app->request->getParam('myLogoutPathParameterName', '/');
}

This defaults to the homepage ('/') if the parameter is not found.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.