Hide Non Activated Users From Member List
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #1
Hide Non Activated Users From Member List
Requirement: XThreads
Based On: Dynamic Board Stats

Just a plugin that I want to share that will hide all users in Awaiting Activation usergroup from member list.

Note:
  • inline_action in AdminCP isn't covered by this plugin.
  • Run the Recount Statistics tools to synchronized the additional cache with the actual data if needed.
  • Admin not affected by this plugin.

Please tell me if there is something wrong with the code.
I'm still learning Biggrin


Attached File(s)
.7z  xtmn_hnau.7z (Size: 1.32 KB / Downloads: 465)

(This post was last modified: 04-08-2012 05:44 AM by RateU.)
01-09-2012 07:31 AM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #2
RE: Hide Non Activated Users From Member List
Wow, nice work RateU Smile

I probably wouldn't have made it as complex as you did (I'd just overwrite the MyBB cache directly), so good work on the effort you put in!

My Blog
01-10-2012 12:22 PM
Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #3
RE: Hide Non Activated Users From Member List
Thanks, Yumi Smile

01-11-2012 02:46 AM
Find all posts by this user Quote this message in a reply
ShadowKyogre Offline
Junior Member
**
Posts: 5
Joined: Apr 2012
Post: #4
RE: Hide Non Activated Users From Member List
I changed up the xtmn_hnau_stats function to also replace the number of registered users to the ones that are currently activated. There's probably a more efficient way to count up all the activated users.

PHP Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
function xtmn_hnau_stats(){
	if($GLOBALS['mybb']->usergroup['cancp'] != 1){
		$lastreguser = $GLOBALS['cache']->read('xtmn_hnau_last_reg_users');
		if(!is_array($GLOBALS['stats'])) $GLOBALS['stats'] = $GLOBALS['cache']->read('stats');
		$GLOBALS['stats']['lastuid'] = $lastreguser['lastuid'];
		$GLOBALS['stats']['lastusername'] = $lastreguser['lastusername'];
		$GLOBALS['cache']->cache['stats'] = $GLOBALS['stats'];
		
		//modify member count on index stats too
		$query = $GLOBALS['db']->simple_select('users','COUNT(*) AS num_users','usergroup!=5');
		$activeusercount = $GLOBALS['db']->fetch_field($query, 'num_users');
		$GLOBALS['stats']['numusers'] = $activeusercount;
		$GLOBALS['cache']->cache['stats'] = $GLOBALS['stats'];
		//end modifications
	}
}

(This post was last modified: 04-06-2012 10:43 AM by ShadowKyogre.)
04-05-2012 02:12 PM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #5
RE: Hide Non Activated Users From Member List
Do a select COUNT(*) (also, ordering doesn't make any sense here)

PHP Code:
		$query = $GLOBALS['db']->simple_select('users','COUNT(*) AS num_users','usergroup!=5');
		$activeusercount = $GLOBALS['db']->fetch_field($query, 'num_users');


Note that you may wish to put an index on the usergroup column if you do this, as the query can be slow if there are a lot of users.


My Blog
(This post was last modified: 04-05-2012 04:55 PM by ZiNgA BuRgA.)
04-05-2012 04:54 PM
Find all posts by this user Quote this message in a reply
ShadowKyogre Offline
Junior Member
**
Posts: 5
Joined: Apr 2012
Post: #6
RE: Hide Non Activated Users From Member List
(04-05-2012 04:54 PM)ZiNgA BuRgA Wrote:  Do a select COUNT(*) (also, ordering doesn't make any sense here)

PHP Code:
		$query = $GLOBALS['db']->simple_select('users','COUNT(*) AS num_users','usergroup!=5');
		$activeusercount = $GLOBALS['db']->fetch_field($query, 'num_users');


Note that you may wish to put an index on the usergroup column if you do this, as the query can be slow if there are a lot of users.


Updated the modification I made earlier to use that method for counting the number of active users. As for the indexing, I would set it up like this, correct?:

PHP Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
function xtmn_hnau_activate(){
	xtmn_hnau_deactivate();
	// check if we have an index on the users table. If not, make it.
	if(!$db->is_fulltext("users") && $db->supports_fulltext_boolean("users"))
	{
		$db->create_fulltext_index("users", "usergroup","activeuser");
	}
	//end change here
	xtmn_hnau_last_reg_users();
}

function xtmn_hnau_deactivate(){
	if(is_object($GLOBALS['cache']->handler)){
		$GLOBALS['cache']->handler->delete('xtmn_hnau_last_reg_users');
	}
	$GLOBALS['db']->delete_query('datacache','title="xtmn_hnau_last_reg_users"');
	// check if we have an index on the users table. If so, drop the index created by the plugin.
	if($db->is_fulltext("users"))
	{
		$db->drop_index("users","activeuser");
	}
	//end change here
}

04-06-2012 10:44 AM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #7
RE: Hide Non Activated Users From Member List
No.
Please read up on MySQL indexing.  Full text indexing is something completely different.

It would be something like

PHP Code:
$db->write_query('ALTER TABLE '.TABLE_PREFIX.'users ADD KEY `usergroup`(`usergroup`)');


EDIT: actually scrap that, MyBB already has an index on the usergroup column, never knew that.
In other words, you don't need to add the index.


My Blog
(This post was last modified: 04-06-2012 11:26 AM by ZiNgA BuRgA.)
04-06-2012 11:23 AM
Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #8
RE: Hide Non Activated Users From Member List
Update:
Count the number of registered users in the Board Stats.

To upgrade, replace the old version with the new one.
Run the Recount Statistics tools.

Thanks, Yumi, ShadowKyogre Smile

04-08-2012 05:51 AM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: