Block New Users From Memberlist MOD

This is a MODification that blocks guests, bots, and new users (Newly registered users) from viewing the full memberlist but still allows member profiles and the online list to be viewed.

Please backup your files before continuing, and if you decide to make these changes, you proceed at your own risk.


Open up memberlist.php and find:

Code: Select all

// Check our mode...
// Original line: if (!in_array($mode, array('', 'group', 'viewprofile', 'email', 'contact', 'contactadmin', 'searchuser', 'team', 'livesearch')))
	
if (!in_array($mode, array('', 'group', 'viewprofile', 'email', 'searchuser', 'livesearch')))
{
	trigger_error('NO_MODE');
}
Then after it, add:

Code: Select all

// Custom restrictions. Blocking guests, bots, and Newly registered users from accessing the full memberlist, despite permissions settings.

if (in_array($mode, array('', 'group', 'searchuser', 'livesearch')))
{
	if ($user->data['group_id'] == 7 OR $user->data['is_bot'])
	{
		trigger_error('NO_VIEW_USERS');
	}
	
	if ($user->data['user_id'] == ANONYMOUS)
	{
		login_box('', $user->lang['LOGIN_EXPLAIN_MEMBERLIST']);
	}
}

// End custom restrictions
When bots and guests have yes permissions for "can view memberlist, onlinelist, and profiles," they will only be able to see profiles and the online list due to this code. Same thing occurs when the group "Newly registered users" has a Yes or No permission set for this. Despite having yes permissions overall, the whole memberlist will be blocked. This will be permanent for bots and guests, and for new users, this will only remain until they have sufficient post count to leave the Newly registered users group.

Note: Newly registered users group must be the user's default group in order for this to work on new users.