vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   How to exclude usergroups condition (https://vborg.vbsupport.ru/showthread.php?t=272844)

vexxy 10-26-2011 06:38 AM

How to exclude usergroups condition
 
I have the following stats code from the widget that displays the total number of users etc. unfortunately, it shows all users, including the ones from waiting for confirmation etc.

What's the condition to exclude them from usergroups 3 and 4?

Code:

ob_start();
global $vbulletin, $db, $vbphrase;
//Begin Forum Stats
// forum stats start
$numbersmembers = $db->query_first("SELECT COUNT(*) AS users,MAX(userid) AS max FROM " . TABLE_PREFIX . "user");
$numbermembers = number_format($numbersmembers['users']);
$counter = $db->query_first("SELECT COUNT(postid) AS posts, COUNT(threadid) AS threads FROM " . TABLE_PREFIX . "post");
$totalposts=number_format($counter['posts']);
$countthreads = $db->query_first("SELECT COUNT(*) AS threads FROM " . TABLE_PREFIX . "thread");
$totalthreads=number_format($countthreads['threads']);
// forum stats end

--------------- Added [DATE]1319662936[/DATE] at [TIME]1319662936[/TIME] ---------------

nobody can help me?

vexxy 10-27-2011 03:20 PM

soo..any help pls? :)

Lynne 10-27-2011 05:07 PM

How about replacing this:
PHP Code:

$numbersmembers $db->query_first("SELECT COUNT(*) AS users,MAX(userid) AS max FROM " TABLE_PREFIX "user"); 

with
PHP Code:

$numbersmembers $db->query_first("SELECT COUNT(*) AS users,MAX(userid) AS max FROM " TABLE_PREFIX "user WHERE usergroupid NOT IN (3,4)"); 


vexxy 10-27-2011 06:27 PM

tnx alot Lynne, wonderful as always

Christos Teriakis 10-29-2011 04:57 AM

In addition to Lynne's advice which is 100% correct, I'm extending the query in case that you want the usergroupid to not exists even in the additional usergroups. You must add in the query:
Code:

AND NOT FIND_IN_SET($usergroupid, membergroupids)
Chris


All times are GMT. The time now is 04:59 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01016 seconds
  • Memory Usage 1,721KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete