Created
July 14, 2021 20:01
-
-
Save jorpdesigns/7f0b013f4215e1c34f3fb3f853ad638e to your computer and use it in GitHub Desktop.
Snippet to set custom login limit
This file contains hidden or 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 | |
// Uses Loggedin – Limit Active Logins plugin: https://wordpress.org/plugins/loggedin/ | |
add_filter( 'loggedin_reached_limit', 'custom_login_limits', 10, 3 ); | |
function custom_login_limits($reached, $user_id, $count) { | |
// Check if user has custom limits and get value (fields added via ACF) | |
$unlimited_query = get_field('unlimited_logins', 'user_' . $user_id ); | |
$user_custom_limit = get_field('logins_limit', 'user_' . $user_id ); | |
if ( (!$unlimited_query) && ($user_custom_limit) ) { | |
$reached = $count >= $user_custom_limit; | |
} | |
return $reached; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment