@magicfilou
No, the free plugin does not include that option.
iThemes Security Pro also does not include the option you described but it does include a module named User Security Check that will allow you to see sessions of who’s logged in — and be able to log them out instantly, everywhere. Not exactly what you are looking for but it does give you some session control.
For more info about the User Security Check module read the article below:
New WordPress User Security Check Helps You Review, Take Action on User Security
Thread Starter
Phil
(@magicfilou)
ok thank you for your quick answer but I really need to block the possibility for users to have several session open at the same time automaticaly.
-
This reply was modified 8 years, 9 months ago by
Phil.
@magicfilou
Try and add this code to your active theme functions.php file:
add_filter( 'authenticate', 'one_session_per_user', 30, 3 );
function one_session_per_user( $user, $username, $password ) {
if ( is_wp_error( $user ) ) {
return $user;
}
$sessions = WP_Session_Tokens::get_instance( $user->ID );
$all_sessions = $sessions->get_all();
if ( count( $all_sessions ) ) {
$user = new WP_Error( 'already_signed_in', __( '<strong>ERROR</strong>: User already logged in.' ) );
}
return $user;
}
Tested, and seems to work but use it at your own risk.
Thread Starter
Phil
(@magicfilou)
Thank you 🙂 Seems to work yes 🙂
little modification for WPML compatibility :
add_filter( ‘authenticate’, ‘one_session_per_user’, 30, 3 );
function one_session_per_user( $user, $username, $password ) {
if ( is_wp_error( $user ) ) {
return $user;
}
$sessions = WP_Session_Tokens::get_instance( $user->ID );
$all_sessions = $sessions->get_all();
if ( count( $all_sessions ) ) {
$user = new WP_Error( ‘already_signed_in’, __( ‘ERROR: User already logged in.’,’login_limit’ ) );
}
return $user;
}
thanks again (y)