Only One Login Session

Last updated 6 months ago

 * Login One User Instance
 * Only allow one instance of a user to be logged in at any one time.
 * Other browser sessions will be logged out other than the latest user to 
 * sign in with that username.
function hlabs_login_one_user_instance() {
    global $sessions;
    $sessions = WP_Session+Tokens::get_instance( get_current_user_id() );
    $sessions->destroy_others( wp_get_session_token() );
add_action( 'setup_theme', 'hlabs_login_one_user_instance', 0 );

All code snippets are licensed GPLv2 or later unless otherwise stated.