MyBB Community Forums

Full Version: Plugin Question
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I can't figure out why this will not work. It works when placed directly in the index.php file, but I can't get it to work as a plugin... The code is...
$plugins->add_hook('index_start', 'onlinetoday');
function onlinetoday()
{
	global $db, $mybb, $templates;
	$todaysmembers = '';
	if($mybb->settings['showwol'] != 0 && $mybb->usergroup['canviewonline'] != 0)
	{
		$todaytime = TIME_NOW-(60*60*24);
		$query = $db->query("
			SELECT u.*
			FROM ".TABLE_PREFIX."users u
			LEFT JOIN ".TABLE_PREFIX."usergroups g ON (g.gid=u.usergroup)
			WHERE u.lastactive > $todaytime
			ORDER BY u.lastactive DESC
		");
		while($user = $db->fetch_array($query))
		{
			if($user['uid'] > 0)
			{
				if($user['invisible'] != 1 || $mybb->usergroup['canviewwolinvis'] == 1 || $user['uid'] == $mybb->user['uid'])
				{
					if($user['invisible'] == 1)
					{
						$invisiblemark = "*";
					}
					else
					{
						$invisiblemark = '';
					}
					$user['username'] = format_name($user['username'], $user['usergroup'], $user['displaygroup']);
					$user['profilelink'] = build_profile_link($user['username'], $user['uid']);
					eval("\$todaysmembers .= \"".$templates->get("index_whosonline_memberbit", 1, 0)."\";");
					$comma = $lang->comma;
				}
			}
		}
	}
}
[/php]
you need to make $todaysmembers Global if you are putting the function in the plugin
Wow, That completely slipped my mind... Thank you for the help.