MyBB Community Forums

Full Version: Mass Mail multiple usergroups
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Is there a mod to mass mail multiple usergroups?

Thanks.

Ps. This can also be a feature suggestion Wink
Admin CP >> Users and Groups >> Mass Email >> Usergroup is:

(send the same email too all usergroups you want)
I know, but I want to be able to select multiple groups at one time.
Well it wasn't that hard to make this modification:
---OPEN---
admin/adminfunctions.php

---FIND---
?>

---BEFORE, ADD---
function makecheckcode($title, $name, $table, $tableid, $optiondisp, $selected="", $extra="", $blank="", $condition="")
{
	global $db;
	$bgcolor = getaltbg();
	echo "<tr>\n<td class=\"$bgcolor\" valign=\"top\" width=\"40%\">$title</td><td class=\"$bgcolor\" valign=\"top\" width=\"60%\">\n";
	if($order)
	{
		$orderby = "ORDER BY $optiondisp";
	}
	if($condition)
	{
		$condition = "WHERE $condition";
	}
	$query = $db->query("SELECT $tableid, $optiondisp FROM ".TABLE_PREFIX."$table $condition $orderby");
	while($item = $db->fetch_array($query))
	{
		if($item[$tableid] == $selected)
		{
			echo "<input type=\"checkbox\" name=\"${name}[]\" value=\"$item[$tableid]\" checked=\"checked\" id=\"${name}_$item[$tableid]\"> <label for=\"${name}_$item[$tableid]\">$item[$optiondisp]</label><br />\n";
		}
		else
		{
			echo "<input type=\"checkbox\" name=\"${name}[]\" value=\"$item[$tableid]\" id=\"${name}_$item[$tableid]\"> <label for=\"${name}_$item[$tableid]\">$item[$optiondisp]</label><br />\n";
		}
	}
	if($extra)
	{
		if($selected == "-1")
		{
			echo "<input type=\"checkbox\" name=\"${name}[]\" value=\"-1\" checked=\"checked\" id=\"${name}_$extra\"> <label for=\"$extra\">$extra</label><br />\n";
		} 
		else
		{
			echo "<input type=\"checkbox\" name=\"${name}[]\" value=\"-1\" id=\"${name}_$extra\"> <label for=\"${name}_$extra\">$extra</label><br />\n";
		}
	}
	echo "\n</td>\n</tr>\n";
}

---OPEN---
admin/users.php

---FIND---
	if($usergroupis != "" && $usergroupis != "-1")
	{
		$conditions .= " AND usergroup='$usergroupis'";
	}

---REPLACE WITH---
	if(array_search(-1,$usergroupis) === FALSE)
	{
		$conditions .= " AND usergroup IN (";
		$groups = "";
		foreach ($usergroupis as $ugroupin) {
			if($usergroupis != "-1")
			{
				$groups .= (!empty($groups)) ? "," : "";
				$groups .= intval($ugroupin);
			}
		}
		$conditions .= $groups . ")";
	}

---FIND---
makeselectcode($lang->group_is, "usergroupis", "usergroups", "gid", "title", "-1", "Any");

---REPLACE WITH---
makecheckcode($lang->group_is, "usergroupis", "usergroups", "gid", "title", "", "Any");

---SAVE AND CLOSE ALL FILES---

Note: the above code looks tab-less since MyBB took out all the excess tabs when I posted it.

I hope I haven't left anything out Smile