Private Area - Login Register Redirect Page

Hello,

If a user lands on a private area page …Is it possible to create a redirect that will take a visitor to a Login or Registration page if they are not Logged-In or Registered with the site?

I read the Create Private Area Documentation But did not see any redirect? Is there a example available?

Thanks in Advance

Well, Login plugin should handle this :slight_smile: If you enter site where access is set in the frontmatter, it’ll redirect you to the login page :slight_smile:

Yes I have added

access:
site.login: true
admin.login: true

But still no luck it just stays on the page and no redirect.

Do you have a Example?

Thanks

Did you remember about the intendation?

access:
    site.login: true

Yes I did indent. Yes Sorry about that but Yes I indented.

And when you enter this page, what does show up?

Nothing shows up its just blank. It looks like it’s protecting it but not sending me to login page.

Did you enable Login module and configure Login-path?

Yes Login Plugin is Enable I did set path on login but I go to a page that is blank as well. No Login Form?

Well, it seems that the plugin is not generating login form…

There seems to be many variables that could stop your login form from showing up … I was able to get it showing up by:

{% block main_content %}

{% include 'partials/login-form.html.twig' %}

{% endblock %}

Key here is the Block name “main_content” instead of “content”… “CONTENT” is the default name in the plugin folder… MAIN_CONTENT is the name I gave in my partials/base.html.twig template

1 Like