MyBB Community Forums

Full Version: 3 random members on Portal page
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello
I want to show 3 random members (their usernames and their avatars) on Portal page.

How can I do that?

Thank you.
Hello

open ./portal.php

Find

eval("\$portal = \"".$templates->get("portal")."\";");
Above it add
	$query = $db->query("SELECT * FROM ".TABLE_PREFIX."users ORDER BY RAND() LIMIT 3");
	while($get = $db->fetch_array($query))
	{
		$username = format_name($get['username'], $get['usergroup'], $get['displaygroup']);
		if($get['avatar'] != '')
		{
			$avatar = "<img src=\"".$get['avatar']."\" />";
		}	
		$profilelink = get_profile_link($get['uid']);
		$users_entries .= "<div>{$avatar}<a href=\"{$profilelink}\">{$username}</a></div>";
	}
		$random_users = "<div>{$users_entries}</div>";

Now in the portal template put
{$random_users}

In the place you want.

I have made a basic style, the core codes you might want to style it in a different way.
Thank you very much.
You are perfect.