function user_limit_count_users in User Limit 6
Same name and namespace in other branches
- 7 user_limit.module \user_limit_count_users()
Counts the number of users on the site.
May or may not count inactive users and user 1 depending on settings. This is the "canonical" function for counting users in User Limit.
Return value
An int representing the number of relevant users.
3 calls to user_limit_count_users()
- user_limit_form_user_register_alter in ./
user_limit.module - Implementation of hook_FORM_ID_alter().
- user_limit_reached in ./
user_limit.module - Calculates whether we reached the number of allowed users on the site.
- user_limit_surpassed in ./
user_limit.module - Calculates whether we surpassed the number of allowed users on the site.
File
- ./
user_limit.module, line 25 - Everything related to User Limit. There are no include files.
Code
function user_limit_count_users() {
$count_uid1 = variable_get('user_limit_uid1', 0);
$active_only = variable_get('user_limit_active', 0);
// count all users
$sql = 'SELECT count(*) FROM {users} WHERE uid <> 0';
// optionally exclude UID1
if ($count_uid1 == 0) {
$sql .= ' AND uid <> 1';
}
// optionally exclude banned users
if ($active_only) {
$sql .= ' AND status = 1';
}
$user_count = db_result(db_query($sql));
return $user_count;
}