Skip to main content

FluentAuth: Already Logged-in Users redirect?

I have a link in my header for users to login. However, when the user is already logged in, the link still goes to the FluentAuth login page as if they are not logged in. Any way to have a redirect for current logged-in users when they click on my login link?

Drive Zone

I use snippet below for redirecting users from landing page (home page) to /portal/ if they are logged in. It may help you, you may need different conditions.

add_action('template_redirect', function () {

    // admin / ajax bypass
    if (is_admin() || wp_doing_ajax()) {
        return;
    }

    // jen pΕ™ihlΓ‘Ε‘enΓ­ uΕΎivatelΓ©
    if (!is_user_logged_in()) {
        return;
    }

    // jen homepage
    if (!is_front_page()) {
        return;
    }

    wp_redirect('https://drivezone.cz/portal/');
    exit;

});

Kevin Watson

Drive ZoneΒ I appreciate the snippet fix! I hope they fix this.

Nicolas D

A native fix would be prefered

Kevin Watson

Nicolas DΒ Despite such a wonderful free plugin, I think this one issue is a huge oversight. In the meantime, I have hidden the Login link by user login condition. But naturally it should not allow people back to the FluentAuth login page.

Nicolas D

Kevin WatsonΒ agree !

I feel they need a premium version of Fluent Auth. As I believe that will help to keep the development of Fluent Auth going stronger forward.

Kevin Watson

Paal Joachim RomdahlΒ I like everything about this plugin, except this one piece.

David Churchill

Why not just use a conditional menu? There are a number of plugins that let you control what users see β€” if logged out show the login link, if logged in show the link to whatever page you need. Or, some themes (Blocksy) even have it built in.

Kevin Watson

David ChurchillΒ That's what I said I did in a comment to Nicolas. But I should not have to do this.

David Churchill

Kevin WatsonΒ sorry, I might be missing something, but not exactly sure how that would work - FA is a security plugin, not link management, so your Login link would always point to the Login page. I use https://en-gb.wordpress.org/plugins/nav-menu-roles/ and always dynamically display links based on the users login/logged out state.

Kevin Watson

David ChurchillΒ You are if you haven't dived into it. It has a login page with login shortcodes ability and magic link login as well. It is more than a security plugin.

David Churchill

Kevin WatsonΒ yes I use it on most of my website for security, blocking login attempts and allowing users to login via their social media profiles. I normally disable the magic link for security.

I use the "Custom Login Redirects" to redirect successful Logins to the users Account page (or for my FluentCommunity websites, I redirect successful logins to the the Feed page) and when they Logout, I take them back to the home page.

But FluentAuth is just a security/authentication plugin, not a menu manager. You can customise the Login/Registration forms and create automations with FCRM, but you would still need to manually control your menu links yourself.

Edit: Checking the FA docs, if you are using the FluentAuth shortcode on a page with redirect_to, it only fires once β€” the moment a user logs in. It won't redirect them again on later visits. Separately, if an already-logged-in user lands back on a [fluent_auth_login] form, it appears to redirect them to the homepage (not your redirect_to URL); if you combined it with the [fluent_auth] shortcode I think it just shows a "you're already logged in" message instead.

Taylor Drayson

I've opened a pull reuqest for this, just waiting for it to be merged.

https://github.com/WPManageNinja/fluent-security/pull/87

I had to completely rewrite the login redirect section of fluentauth. It’s now disabled and entirely replaced by custom code that handles already logged in users, redirection to protected pages after login/register, and many other things.

There are many other things that should be added to FluentAuth, including social login with LinkedIn.

There are also bugs with social login and magic login that I had to resolve in order to be able to use these. I made a PR in the github for the bug fixes, so hopefully they will be corrected in the next version, but the login redirect rewrite is too big for a PR.

They should also support login protection to prevent credentials sharing, which is crucial for a membership site. I use a separate plugin for that. Hopefully, FluentAuth will get some TLC at some point, it’s a great plugin but it needs some serious improvements. It might be too small to get a premium version.

Kevin Watson

Screenplay UnlimitedΒ I use the plugin, "Loggedin - Limit Concurrent Sessions" to manage concurrent logins

Kevin WatsonΒ Yes, that's the one I use too. Still, it would be nice to include this into FluentAuth.

Kevin Watson

Thanks everyone for your comments here. Maybe the ninja team will see this and make adjustments.