vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.0 Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=33)
-   -   Number of new members statistic on forum home (https://vborg.vbsupport.ru/showthread.php?t=69392)

Spinball 09-12-2004 10:00 PM

Number of new members statistic on forum home
 
I wanted to show potential advertisers as well as potential forum members how many people are registering to use our forums every day.
So I wrote this hack to display a 30 day average in the stats box of the forum home. It counts the number of people in user group 2 - registered members, ignoring those people who haven't activated their accounts, yet.
It's very easy, takes just a few minutes and requires 1 additional query.
You can see it working at www.avforums.com.
Please click Install if you use it.
Thanks to Bryan Ex for doing a bit of bug fixing help :)

Bryan Ex 09-13-2004 02:58 PM

Great idea... well, at least for active forums. LOL Adding it in today - thanks!

Bryan Ex 09-13-2004 03:08 PM

Something you will likely get asked about is a query to update the stats after a new install. I can see many not wanting to display 0.00 to start out with.

Spinball 09-13-2004 03:49 PM

I doubt anyone having done a new install will want to have this hack working for a wee while. Anyway all they'll have to do is revert back to the original FORUMHOME template. Glad you think it's useful.

Bryan Ex 09-13-2004 03:58 PM

LOL... yeah, that I agree with but what I meant was even for an established board the stats start out at 0 and I would presume it will take a month for them to be accurate (each day that passes getting a little closer). I've done exactly what you've suggested and left it installed but commented out the forum display until later this month when it looks a little better. I'll just have to remember to uncomment next month. Nice hack though and it will be very helpful to me.

M1th 09-13-2004 03:59 PM

You could use the round() function to get a whole number out of the average. :)

Spinball 09-13-2004 04:21 PM

Quote:

Originally Posted by M1th
You could use the round() function to get a whole number out of the average. :)

Just change the new line in the index.php script from

PHP Code:

$averageregistrations vb_number_format($userstats['averageregistrations'],2); 

to
PHP Code:

$averageregistrations vb_number_format($userstats['averageregistrations']); 

i.e. remove the ',2'. I deliberately wanted to specify a couple of decimal places. Makes the stats look more scientific :)

Polo 09-13-2004 05:58 PM

Nice Hack, I like it :)

Johnny 09-13-2004 08:00 PM

i dont understand how this mod works spinball...

i looked on ur site and it says:
New registrations per day (30 day average): 66.20

whats the decimal part for? i thought each new register counts as one and not as a decimal

Bryan Ex 09-13-2004 08:03 PM

It's averaged over a 30 day period... in this case 1986 new joins in 30 days (1986 / 30).

Johnny 09-13-2004 08:19 PM

o ok, so basicly a percentage... i see now, thx. and nice hack

Spinball 09-13-2004 10:17 PM

Not a percentage, no. An average.

Yeah how do you show how many people are registering?
Just showing the number of people in the last day doesn't represent what is really going on since it could be a particularly busy or quiet day.
So it seems fair to show the number of users in the last month or so. Well 30 days.
I think it sounds impressive if you quote the number of new users per day as an average with decimal points. It makes you look 'on the ball' with what's happening on your forum.

kall 09-13-2004 10:30 PM

Of course, all this assumes that none of your Registered members move into other Usergroups in this time, through Promotions or what have you.

I would probably use something more like
PHP Code:

user WHERE usergroupid NOT IN 3 

(assuming I didn't want to count the unconfirmed email ones).

Spinball 09-13-2004 10:40 PM

I thought about this. For reasonably 'vanilla' boards like ours, there aren't any other user groups. However if I were excluding user groups rather than including them I would exclude banned and awaiting coppa users, too.

kall 09-13-2004 10:43 PM

Quote:

Originally Posted by Spinball
I thought about this. For reasonably 'vanilla' boards like ours, there aren't any other user groups. However if I were exclusing user groups rather than including them I would exclude banned and awaiting coppa users, too.

Indeed. The query for that would be a bit more complicated than my just-woke-up brain can pull out of the ether at the moment tho. :)

Although, the banned ones are still new members...

Spinball 09-13-2004 10:49 PM

Quote:

Originally Posted by kall
Indeed. The query for that would be a bit more complicated than my just-woke-up brain can pull out of the ether at the moment tho. :)

Although, the banned ones are still new members...

I'm somewhat experienced in SQL so I can do that later.
Yes banned members can also be considered new members. But if you are being true to yourself and your advertisers, you don't count members who aren't going to contribute.

Bryan Ex 09-14-2004 07:06 AM

Hmmm... something isn't right here. My stats have been at 0.00 all day with over 100 joins. Two lines of code and I've spent an hour trying to figure it out (feeling like a dork the whole time). Has anyone else actually done an install on this one?

Spinball 09-14-2004 04:36 PM

Is user group 2 registered members, Bryan?

To see it in a manual way, go to your admin CP / Statistics & Logs / Statistics / Registration Statistics and highlight and copy (CTRL+C) the contents of the table (all 3 columns - date, graphic bar and number) into memory.
Then open word and paste in there.
Highlight and delete the first two columns leaving the table of numbers.
Then in Word do a convert table to text. Doesn't matter what seperator is specified.
Then copy the lot and paste into an Excel spreadsheet.
Sum the numbers (highlight from the top number all the way down to the empty cell below the bottom number and click the sum button).
Then in calculator, enter the total and divide by the number of rows (it'll be 30 or 31).
And that's your average number of new registrations in total over the last 30 or 31 days.
The manual method is long winded and doesn't excluded non-activated registrations, but it's a way to get the numbers wthout hacking.

The hack is a lot easier in the long run :)

Bryan Ex 09-14-2004 04:46 PM

Quote:

Originally Posted by Spinball
Is user group 2 registered members, Bryan?

Yep... usergroup 2. I'm not getting any type of error and everything seems to run properly. I'm just not getting any data output on Forum Home. I am using 3.0.1 but that shouldn't matter for this... or would it?

Spinball 09-14-2004 05:45 PM

My honest answer is that I don't know - but I wouldn't have thought so.
It being 0.00 would indicate that the numeric value is either not being returned properly from the SQL query or passed from that query though to the data array.
Can you run the query on your database to see if that bit works?

Bryan Ex 09-15-2004 06:00 AM

Good idea... I never thought to try that. Running just the query returned a count of 85.77. Just wondering if anyone else has actually installed this and has it working? Not sure how I could screw up two lines of code but if it works for someone else then I at least know it's specific to me and not the code itself.

Spinball 09-15-2004 06:25 AM

That's an impressive registration rate. If the query is working ok then all you've got to do is get that returned value into the right variable available on the home page.
Can you 'read' php? Have a look at the code to see if it looks right.
The code I used in the installation notes came copied from my installation which works perfectly.

Bryan Ex 09-15-2004 06:43 AM

The part I don't understand is that in functions_databuild it refers to $avgregs = yet that variable is not referenced anywhere else - like in index.php for example. Is that correct? If I follow the data process for my site $avgregs would equal 85.77 but what calls that data to index.php? It's as if there's a part missing or something.

Bryan Ex 09-15-2004 07:13 AM

I think I know what's missing. I believe there should also be an edit to the array in functions_databuild.php...

// make a little array with the data
$values = array(
'numbermembers' => $members['users'],
'newusername' => $newuser['username'],
'newuserid' => $newuser['userid']
);

Bryan Ex 09-15-2004 07:51 AM

This is what I thought it should be but it still isn't right. Could you check your functions_databuild file for this array?

PHP Code:

    // make a little array with the data
    
$values = array(
        
'numbermembers' => $members['users'],
        
'newusername' => $newuser['username'],
        
'newuserid' => $newuser['userid'],
        
'averageregistrations' => $avgregs['regcount']
    ); 


Spinball 09-15-2004 12:48 PM

Many apologies - yes you are right.
I omitted that part and have updated the text instructions.
Anyone installing so far will need to amend that bit.
Thanks for your help.

Bryan Ex 09-15-2004 01:13 PM

Just to confirm... it's now working fine for me. Thanks Spinball.

Bryan Ex 09-15-2004 02:48 PM

This is strange indeed. I do have a member count showing now but it is incorrect and any changes I make to the query doesn't seem to affect it. For example I changed the user group ID but the same count as before shows or I changed (userid)/30 to /60 which should drop the number by half, again no change. I then thought maybe it's cached somewhere so cleared my temp files and manually ran all board maintenance tasks with no luck. I believe it's really close... but something still isn't quite right unless I'm missing something obvious. Any ideas or suggestions Spinball?

(Can you tell I really want to get this working? LOL)

Spinball 09-15-2004 02:58 PM

It's COUNT(userid)/30 as regcount. What should it be and what is it via the hack?
If you change the 30 to 60 you need to do it in 3 places. The 2 in the SQL statement and the 1 in the phrase.

Bryan Ex 09-15-2004 04:09 PM

Yep, understand that part. What I was getting at was that the stats were not being dynamically updated but I think I now know why. Any changes I make to the query do not take affect until the next person joins. In other words, something has to happen before the number updates (a simple page refresh makes no difference). I think I'm sorted out now so just ignore my ramblings...lol.

lange 11-07-2004 12:12 PM

Thanks, I'll try it.


All times are GMT. The time now is 09:20 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.01184 seconds
  • Memory Usage 1,807KB
  • 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
  • (4)bbcode_php_printable
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (31)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