• Resolved edwardboswell

    (@edwardboswell)


    The plugin works fantastically. But I was wondering if there is a way to flash a message to the user as of why he/she got logged out.

    I currently have a membership site. When they get logged out, they are redirected to the home page. I want the message to show that they are not allowed to share login info and they were logged out automatically due to this.

    https://www.ads-software.com/plugins/prevent-concurrent-logins/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Frankie Jarrett

    (@fjarrett)

    The Prevent Concurrent Logins plugin doesn’t handle redirections, so something else is hooking into WordPress and doing that.

    By default, when a user tries to access the WP Admin, and their session is expired, WordPress will either send them to the login screen or if heartbeat catches it there will be a lightbox login with a special message that their session has expired.

    Example: https://note.io/1M3HWKC

    It sounds like you may be requiring users to be logged in to view certain front-end content as well, which means there is probably a membership plugin of some kind on your site that is causing them to be redirected to your homepage.

    Thread Starter edwardboswell

    (@edwardboswell)

    Sorry, I didn’t clarify to well.

    I do have a membership plugin, s2member, and some custom hooks for redirection as well.

    I was just wondering if there was a way on the front end to send a message via Ajax to tell them why they got logged out. I have no problem modifying my theme, but was wondering if there was a way to hook into your plugin so I can output the message.

    Thanks for the awesome and quick response!

    Thread Starter edwardboswell

    (@edwardboswell)

    Never Mind, I found a way through my membership plugin. I love your plugin, its very quick and easy to use.

    Thank you for the help

    Plugin Author Frankie Jarrett

    (@fjarrett)

    Hey Edward, no worries.

    This plugin uses the wp_destroy_other_sessions function that was newly added in WP 4.1 to destroy a current user’s old sessions.

    So I think what you are wanting to achieve is beyond the scope of what this plugin does – there is not a place to hook in.

    The easiest way to do what you want is to modify s2member so the WP default behavior is used and users are sent to the wp-login.php page when their session is expired and they attempt to view a page designated for loggin-in users only.

    When WP redirects to the login screen there is a query var called reauth=1 in the URL which indicates that the user needs to be reauthenticated, we can assume this also means that WP knows they were previously authenticated but now for some reason they aren’t anymore. So then you can redirect wherever you want if that query var exists.

    function my_login_redirect_for_expired_sessions() {
    	if ( 1 != get_query_var( 'reauth' ) ) {
    		return;
    	}
    
    	wp_safe_redirect( home_url( '/my-custom-login-screen/' ) );
    
    	exit;
    }
    add_action( 'login_init', 'my_login_redirect_for_expired_sessions' );
    

    The code above is untested, but this is the most support I can provide for this issue ??

    Good luck!

    Plugin Author Frankie Jarrett

    (@fjarrett)

    Thanks, Edward! I would greatly appreciate a short five star review!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Option Request’ is closed to new replies.