1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How does XenForo count registered members?

Discussion in 'XenForo Questions and Support' started by Grover, Jan 24, 2011.

  1. Grover

    Grover Well-Known Member

    I am investigating switching my platform from vBulletin to XenForo in the future and I wondered this:

    On vBulletin my statistics (on the frontpage) show this:

    However, when you go to the memberlist http://www.mysite.com/forum/memberlist.php then the amount of members is much less (in my case... about 4.000 members less!). I assume because in the memberlist only members who have clicked on the link in their registration-confirmation email are listed. So members who missed this email (in 99% of the cases due to #@#$% spam filters) are not listed and are in fact not a 'real' member, since they are not able to post and are basically still just 'guests'.

    First it is strange that vBulletin shows 2 different amounts, but this is not a vBulletin support forum is it? ;). What I would like to know is: what happens if I transfer my vBulletin site to XenForo? Will XenForo still list the same amount of members on the XF frontpage as it is listed on my current vB frontpage? Or will XF list the amount of members on the frontpage that vBulletin lists in the Memberlist?

    It's a small thing ofcourse, but our celebrating member-milestone announcements :) are based upon the number on the frontpage, so if XF would switch that number to the 'Memberlist' number, we will suddenly be going down in the our 'official' member count.
  2. Mike

    Mike XenForo Developer Staff Member

    XF only counts users that have validated their accounts. It also doesn't count banned users either. So your total user count will likely go down.
  3. ragtek

    ragtek Guest

    XF counts AFAIK only the users which have validated there account.

    Edit: grr, mike was faster^^
  4. Grover

    Grover Well-Known Member

    Thank you for taking the time to confirm.
  5. James

    James Well-Known Member

    Presumably it only omits permanently banned users? I'd still class my temporarily banned users as members, just ones who went astray a little.
  6. Dean

    Dean Well-Known Member

    I've not tested it, but I would assume that while they are banned they are not counted, but when they become unbanned they are counted.
  7. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    It doesn't count any bans, permanent or temporary. I just tested it.

    If you are curious:


    	 * Gets the count of total users.
    	 * @return integer
    	public function countTotalUsers()
    		return $this->_getDb()->fetchOne('
    			SELECT COUNT(*)
    			FROM xf_user
    			WHERE user_state = \'valid\'
    				 AND is_banned = 0
    James likes this.
  8. James

    James Well-Known Member

    How often is that query ran Jake? Just curious!
  9. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Every 10 minutes. It's part of:

    Admin CP -> Tools -> Cron Entries -> Rebuild Board Totals Counter
  10. James

    James Well-Known Member

    Ahh, thanks Jake. I would've checked but I don't have access to my install on my current laptop. I wonder if it'd make more sense to run the cron job when a new user is registered/banned? It'd be more efficient than every 10 minutes, I'm sure.

    Then again if I remember rightly excess queries aren't something Kier is prone to, so I'm probably overlooking something!
  11. Dean

    Dean Well-Known Member

    Right. So while they are banned they are not counted, and when they become unbanned they are then counted.

  12. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    The server overhead of that cron is negligible. It's not worth worrying about.

    Note that the other forum stats are also updated by that cron including the total number of posts and the latest registered user.

    Dean likes this.
  13. Veer

    Veer Well-Known Member

    Jake, I tried this line:
    WHERE user_state = \'valid\', \'email_confirm\', \'email_confirm_edit\', \'moderated\'

    but getting error when run the cron

    Mysqli prepare error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' 'email_confirm', 'email_confirm_edit', 'moderated' AND is_banned = 0' at line 3
  14. ragtek

    ragtek Guest

    Your query isn't ok!
    If you want to get ALL members you need to remove the "WHERE " part

    But instead of changing the original XF file, you should create your own class & method for this and overwrite the orignal one with the xenforo plugin system;)
    Jake Bunce likes this.
  15. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    ragtek is correct. Your query isn't syntactically valid. The correct query to count all users (for use in an addon ideally) is:

    FROM xf_user
    Or to exclude invalid accounts (awaiting email confirmation or moderation by the admin):

    FROM xf_user
    WHERE user_state = \'valid\'
    If you are a programmer then you can post in the Development Questions forum for help writing an addon. Or post an Add-on Request and some one may be able to write this for you.
  16. giorgino

    giorgino Well-Known Member

    Is there an environment variable that list all users?
  17. Jeremy

    Jeremy Well-Known Member

    No. The members list is the closest. You can view all members in the ACP.
    giorgino likes this.
  18. sadiq6210

    sadiq6210 Active Member

    I was looking for this

    Thanks Jake

Share This Page