Info
- 17 posts
- 6 voices
- Started 2 years ago by bb-lover
- Latest reply from chrishajer
How to Show Total Registerd Users In Forum?
-
- Posted 2 years ago #
hi to all :-)
i want to show just resisted users in my forum's footer. how it will possible. but i don't want to install mini-stats plugin.... and listen dears.... when we go to the dashboard of bbpress... there we can see the total resisted users in the "Right Now" Column. So I just want to show registed users in footer like thatTotal resisted users : e.g 500
plz guide
-
- Posted 2 years ago #
Hi bb-lover
I recently wanted the same thing in my forum. I did not want to install complex plugins.
If you're looking for something like this: http://www.inniosoft.co.cc/devstation (look at the bottom), then you need to add the following to your footer.php file in your template's directory:
<?php function show_total_users() { global $bbdb, $bb_table_prefix; $totalusers = $bbdb->get_var( "SELECT COUNT(*) FROM ".$bb_table_prefix."users USE INDEX (PRIMARY);" ); echo "".$totalusers.""; } ?>Hope that helps :)
Michael
-
- Posted 2 years ago #
No Michael....... Its not working :-(
I think you've installed mini_stats plugin...................right?
so show me complete footer file or tell me the plugin which you've used along this script....thanx
-
- Posted 2 years ago #
I uninstalled Mini-stats because I don't like it. That script should be working.
My statistics come from manually editing files - the plugins are not very helpful to me.
I did write my own plugin - though you have to do manual editing to get the information to show. Simply add the following code to stats.php and place it in your plugins folder - and activate.
<?php /** * Plugin Name: General Statistics * Plugin Description: Collects general statistics about the forum, including the newest users, online guests, and topic/post counts. * Author: Inniosoft * Author URI: http://www.inniosoft.co.cc * Version: 0.1 */ $mysql41 = true; // Change this if you have regular database problems function show_newest_users() { global $bbdb, $bb_table_prefix; $count = 3; // Edit this value to change how many users get displayed. if ($newestuser = $bbdb->get_results("SELECT * FROM ".$bb_table_prefix."users ORDER BY ID DESC LIMIT 0,".$count."")) : $counter = 0; foreach ($newestuser as $nu): $counter++; if ($count != 1 && $count > $counter) : if ($counter == $count - 1): if ($count == 2): $comma = " and "; else: $comma = ", and "; endif; else: $comma = ", "; endif; else : $comma = ""; endif; if ($counter == $count) : if ($count > 1) : $stop = "."; else : $stop = ""; endif; else : $stop = ""; endif; $user = bb_get_user($nu->ID); $userdisplayname = (empty($user->display_name) ? $user->user_login : $user->display_name); $userprofilelink = get_user_profile_link($nu->ID); echo "<a href=\"".$userprofilelink."\" title=\"See ".$userdisplayname."'s Profile\">".$userdisplayname."</a>$comma$stop"; endforeach; else : echo "Unable to fetch newest members(s). An error occured within the database."; endif; } function show_total_users() { global $bbdb, $bb_table_prefix; $totalusers = $bbdb->get_var( "SELECT COUNT(*) FROM ".$bb_table_prefix."users USE INDEX (PRIMARY);" ); echo "".$totalusers.""; } function show_total_posts() { global $bbdb, $bb_table_prefix; $totalposts = $bbdb->get_var( "SELECT SUM(posts) FROM ".$bb_table_prefix."forums;" ); echo "".$totalposts.""; } function show_total_topics() { global $bbdb, $bb_table_prefix; $totaltopics = $bbdb->get_var( "SELECT SUM(topics) FROM ".$bb_table_prefix."forums;" ); echo "".$totaltopics.""; } ?>Then, to show the information, add the following to either
front-page.phpor `footer.php:We have <b><?php show_total_users(); ?></b> registered members. Welcome to our newest members: <?php show_newest_users(); ?><br /> Our members have made a total of <b><?php show_total_posts(); ?></b> posts in <b><?php show_total_topics(); ?></b> topics.</td> -
- Posted 2 years ago #
I'm just trying this and I get the follow error:
We have registered members. Welcome to our newest members: Unable to fetch newest members(s). An error occured within the database. Our members have made a total of 0 posts in 0 topics. -
- Posted 2 years ago #
I can't see why it is giving you that error. Did you install the plugin properly? It should work 100%
-
- Posted 2 years ago #
Its not working................ topix and posts are displaying but not users........... i want to clear that i've integrated my bbpress and wordpress...that's why the users table of both software s are same in one database i.e. wp_users
also i want to mention here........I've set the table prefix of bbpress bb_ into uk_ because of multiple bbpress installations.so that's my detail...and i'm going curious to listen abt new script from your side. :-)
-
- Posted 2 years ago #
That function is already on core, you just have to include it:
<?php include_once("bb-includes/functions.bb-statistics.php"); ?>
And then call it:
<?php echo get_total_users(); ?> -
- Posted 2 years ago #
@ matveb
I got it ........Thanks dear... you code is simple and smart :-) -
- Posted 2 years ago #
Actually, one amend: you should use
<?php total_users(); ?>which is meant for output and you get rid of theecho.Glad it worked.
-
- Posted 2 years ago #
@matveb
Thanks both are working..........
<?php echo get_total_users(); ?>
and
<?php total_users(); ?>but i don't know why i should not use echo.... is it bad for me?
tell me about pros and cons of echo... thanks :-)
-
- Posted 2 years ago #
@ Michael888
I've installed it propertly, maybe I should note that I've integrated bbpress with wordpress and that my wordpress installation is in a diffrent database then my bbpress. (And that wordpress doesn't use the default prefix)
My site is:
http://somerandomlife.com/forum -
- Posted 2 years ago #
No, it is not bad. It's just that if you want to output a result and there is already a function in place doing just that, why not use it? Basically total_users is doing the same as echo get_total_users.
For what it matters, it is less code :) -
- Posted 2 years ago #
I see - I never designed the plugin to be published - it was specifically for my forum. So I'm not sure how I'd get everything working there for an intergrated WP.
@fundomaat: I'd really love to know how you got the "Members online today" thing. I've been trying to do it myself - but I'm not sure how. Also, I don't want to experiment because my PC keeps lagging an I'm constanly loosing files over FTP. I can fix that soon enough though...
-
- Posted 2 years ago #
@ matveb
dear i want to show newly add user then what should i do? I've called this query <?php newest_users(); ?>
but its not works...plz help -
- Posted 2 years ago #
this is somewhat related: I noticed stats.php in the default template, how do you go to it?
-
- Posted 2 years ago #
http://bbpress.org/forums/statistics.php (statistics.php on your forum)
-
You must log in to post.