| 开发者 |
joelcj91
duckdev |
|---|---|
| 更新时间 | 2025年11月11日 21:07 |
| 捐献地址: | 去捐款 |
| PHP版本: | 7.4 及以上 |
| WordPress版本: | 6.8 |
| 版权: | GPLv2 or later |
| 版权网址: | 版权信息 |
You can find the plugin settings by navigating to Users > Loggedin in your WordPress admin dashboard.
Currently, the plugin offers three built-in login logic options:
The duration of a login session is determined by WordPress's default settings.
auth_cookie_expiration filter. Here's an example of how to set the session to one month:
```php
function custom_auth_cookie_expiration( $expire ) {
return MONTH_IN_SECONDS; // Sets the session to one month
}
add_filter( 'auth_cookie_expiration', 'custom_auth_cookie_expiration' );
```
Administrators can forcefully log a user out of all their active sessions from the dashboard.
Yes, you can bypass the limit for certain users or roles by adding a few lines of code to your theme's functions.php file or a custom plugin.
To bypass specific user IDs, use the following code:
```php
function loggedin_bypass_users( $bypass, $user_id ) {
// Add the user IDs you want to bypass to this array.
$allowed_users = array( 1, 2, 3, 4, 5 );
return in_array( $user_id, $allowed_users );
}
add_filter( 'loggedin_bypass', 'loggedin_bypass_users', 10, 2 );
```
To bypass specific user roles, use this code:
```php
function loggedin_bypass_roles( $prevent, $user_id ) {
// Add the roles you want to bypass to this array.
$allowed_roles = array( 'administrator', 'editor' );
$user = get_user_by( 'id', $user_id );
$roles = ! empty( $user->roles ) ? $user->roles : array();
return ! empty( array_intersect( $roles, $allowed_roles ) );
}
add_filter( 'loggedin_bypass', 'loggedin_bypass_roles', 10, 2 );
```