Last active
January 18, 2019 14:09
-
-
Save mattwatsoncodes/a041241f714b2fbd76c09c10cb52ebde to your computer and use it in GitHub Desktop.
Login one user instance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* 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 mwtsn_example_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', 'mwtsn_example_login_one_user_instance', 0 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment