Allowing guests, bots, and new users to view profiles but not the whole memberlist.

Custom coding for various phpBB versions as well as other useful scripts.
Array
Dimetrodon
Not A Dinosaur!
Not A Dinosaur!
Posts: 197
Joined: Mon Sep 12, 2022 9:30 am
Verification: ✅ Elon Musk Style

Allowing guests, bots, and new users to view profiles but not the whole memberlist.

Post by Dimetrodon »

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.
Last edited by Dimetrodon on Sun May 28, 2023 5:36 pm, edited 3 times in total.