Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't show the login button if you're already logged in #159

Open
neonnero opened this issue Dec 19, 2019 · 4 comments
Open

Don't show the login button if you're already logged in #159

neonnero opened this issue Dec 19, 2019 · 4 comments
Assignees
Labels
enhancement Issues & PRs related to new features. good first issue
Milestone

Comments

@neonnero
Copy link

neonnero commented Dec 19, 2019

I'd like to have additional options when using a separate login button ([openid_connect_generic_login_button]).
My suggestions:

  • Don't show the login button if you're already logged in
  • Customize the button label text
  • When using a separate login button (using a shortcode), enable that the user can be redirected back to the page they were on after logging in

This could also be extended to a post/page general options, for articles/pages where login may be required to show the full text.

@timnolte
Copy link
Collaborator

timnolte commented Apr 7, 2021

@neonnero your second 2 items should be fully handled with either some existing changes or some changing coming in the next release. Your first request will still need to be looked at.

@timnolte timnolte self-assigned this Apr 7, 2021
@timnolte timnolte added the enhancement Issues & PRs related to new features. label Apr 7, 2021
@backpackingseries
Copy link

Is this possible now?

Don't show the login button if you're already logged in

At this time, I am using Gutenberg blocks to set display conditions for logged-in and logged-out users. But it'd be nice to have this as a native feature. Thanks

Kind regards,

@timnolte
Copy link
Collaborator

The second two items already exist with the short code. Not showing the button when logged in is something I don't believe has been implemented yet.

@zabalajka
Copy link

Don't show the login button if you're already logged in

At this time, I am using Gutenberg blocks to set display conditions for logged-in and logged-out users. But it'd be nice to have this as a native feature.

CSS solution/workaround

Actually, this can be achieved by just CSS (see this answer and WordPress documentation for more details), because the <body> will have class logged-in for autheticated user and based on this we could show/hide the login button.

[openid_connect_generic_login_button button_text="Login"]
<a class="oidc-login-link" href="[openid_connect_generic_auth_url]">Login</a>
<a class="oidc-logout-link" href="/wp-login.php?action=logout">Logout</a>
body.logged-in .openid-connect-login-button,
body.logged-in .oidc-login-link,
body:not(.logged-in) .oidc-logout-link
{
  display: none;
}

Would something like this be sufficient for you @neonnero ?

Shortcode option

However, I understand that option within the plugin would be nice for this. For example, shortcode option display could be added [openid_connect_generic_login_button display="logged-out"] with possible values:

  • always (default) - current behaviour, backwards compatible
  • auto - show login button only for anonymous user

Since the plugin supports end_session endpoint, we could create shortcode for the Logout button/url as well with the same option to define visibility.

What do you think @timnolte ? (I have a working code for the login button.)

@timnolte timnolte changed the title Option to create custom login buttons Don't show the login button if you're already logged in May 11, 2023
@timnolte timnolte added this to the 3.10.0 milestone May 11, 2023
@timnolte timnolte modified the milestones: 3.10.0, 4.0.0 Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Issues & PRs related to new features. good first issue
Projects
Development

No branches or pull requests

4 participants