MyBB Community Forums

Full Version: private usergroup questions
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
The gist of this is I am a setting up a private (company) forum within a public site. Accordingly I have setup a new category and child forums visible only to members of the Blue Group and the admin.

In a perfect world, I would like to make it as easy as possible for these new members to register and be admitted to the Blue group and keep them as invisible as possible to the public forums.

Most of them will use a company email address - can I somehow use that as a filter?

Alternatively, can I manually add their names somewhere so that as soon as they register they can immediately "see" the private forums?
Attached is a small plugin you could use.
Just change "@googlemail.com" to whatever email you want and put at ""usergroup" => 4" the id of your "blue group".

It will put all users that register to your desired group if a part of their email address machtes.
Wow. That's pretty cool!

What is the syntax for more than one email address? (I have 4 or 5 companies to fold into this.)

Thanks!
My test user reports:

Quote:Warning [2] array_merge() [function.array-merge]: Argument #1 is not an array - Line: 295 - File: inc/class_session.php PHP 5.2.17 (Linux)

so I'm guessing there is a syntax error ... ?
I've tested this plugin with mybb 1.6.5 and it works nicely.

For multiple groups change the function to something like this:
function usergroupbyemail_putingroup()
{
	global $db, $mybb, $user_info;
	
	if(preg_match("/@mail_1.com/i", $user_info['email']))
	{
		$bluegroup = array(
					"usergroup" => 6
					);
		$db->update_query("users", $bluegroup, "username = '".$user_info['username']."'");
	}
	if(preg_match("/@mail_2.com/i", $user_info['email']))
	{
		$redgroup = array(
					"usergroup" => 7
					);
		$db->update_query("users", $redgroup, "username = '".$user_info['username']."'");
	}
	if(preg_match("/@mail_3.com/i", $user_info['email']))
	{
		$greengroup = array(
					"usergroup" => 8
					);
		$db->update_query("users", $greengroup, "username = '".$user_info['username']."'");
	}
	if(preg_match("/@mail_4.com/i", $user_info['email']))
	{
		$yellowgroup = array(
					"usergroup" => 9
					);
		$db->update_query("users", $yellowgroup, "username = '".$user_info['username']."'");
	}
	if(preg_match("/@mail_5.com/i", $user_info['email']))
	{
		$pinkgroup = array(
					"usergroup" => 10
					);
		$db->update_query("users", $pinkgroup, "username = '".$user_info['username']."'");
	}
}

In the previous example you would put every company member in its own group. If you want to put the members of all companies in the same group you can use the following function.
function usergroupbyemail_putingroup()
{
	global $db, $mybb, $user_info;
	
	if(preg_match("/@mail_1.com/i", $user_info['email']) or preg_match("/@mail_2.com/i", $user_info['email']) or preg_match("/@mail_3.com/i", $user_info['email']))
	{
		$bluegroup = array(
					"usergroup" => 6
					);
		$db->update_query("users", $bluegroup, "username = '".$user_info['username']."'");
	}
}