开发者 | fjarrett |
---|---|
更新时间 | 2016年8月17日 06:21 |
PHP版本: | 4.1 及以上 |
WordPress版本: | 4.6 |
版权: | GPL-2.0 |
版权网址: | 版权信息 |
This plugin does not have a settings page. Simply put, I don't like bloating my plugins with a bunch of options. Instead, I try to develop functionality using the 80/20 principle so that for 80% of use cases you all you need to do is activate the plugin and it "just works". For the other 20% of you who want things to behave differently there are hooks available in the plugin so you can customize default behaviors.
Yes, simply add this code to your theme's functions.php
file or as an MU plugin:
function my_pcl_whitelist_user_ids( $prevent, $user_id ) {
$whitelist = array( 1, 2, 3 ); // Provide an array of whitelisted user IDs
return in_array( $user_id, $whitelist ) ? false : $prevent;
}
add_filter( 'pcl_prevent_concurrent_logins', 'my_pcl_whitelist_user_ids', 10, 2 );
Or this code to bypass users with certain roles:
function my_pcl_whitelist_roles( $prevent, $user_id ) {
$whitelist = array( 'administrator', 'editor' ); // Provide an array of whitelisted user roles
$user = get_user_by( 'id', absint( $user_id ) );
$roles = ! empty( $user->roles ) ? $user->roles : array();
return array_intersect( $roles, $whitelist ) ? false : $prevent;
}
add_filter( 'pcl_prevent_concurrent_logins', 'my_pcl_whitelist_roles', 10, 2 );