MyBB Community Forums

Full Version: Templates
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
How do I stop the Statistics template index_stats being displayed to people who have not logged in?

I then want to display a new template that only people who are not logged in can see.

Thanks I had read that thread and was thinking about useing the welcomeblock_guest template but how do I prevent the statistics template from showing.
May way needs work but maybe you could approve upon it.

Open "stats.php"
Find: $stats = $cache->read("stats");

Below Add: if ($mybbuser['usergroup'] == "1") {
die('You must be logged in to view this content');
}



EDIT: Actually this code doesn't work. Well Not for guests alteast because it does work for members in the admin group
I.E. if ($mybbuser['usergroup'] == "4") {
echo "Hello Admin";
}

There should be a conditional to see if the person is logged in or not.
find
// Get Forum Statistics
if($mybb->settings['showindexstats'] != "no")
{
in index.php and replace with
// Get Forum Statistics
if($mybb->settings['showindexstats'] != "no" && $mybbuser['uid'] != "0")
{
right k776 ive done that, is there anything else I need to change as the statistics are still shown when not logged in?
I have tried k776's method but it didn't work for me either.

In your admin panel add a new template named "stats_denied"
<html>
<head>
<title>$settings[bbname]</title>
$headerinclude
</head>
<body>
$header

<table class="tborder" cellpadding="6" cellspacing="1" border="0" width="100%" align="center">
<tr>
	<td class="thead" align="left">title here</td>
</tr>
<tr>
	<td class="trow1" align="left">
$denied

	</td>
</tr>
</table>


<br />

$footer
</body>
</html>

Save Template

Open stats.php
-Find-
$stats = $cache->read("stats");

-After Add-
if($mybb['uid'] != "0") {

-Find-
outputpage($stats);

-After Add-
} else { 

	$denied = "You must be logged in to view the stats page";
	eval("\$denied = \"".$templates->get("stats_denied")."\";");
	outputpage($denied); 
  }

Save and upload

http://harmor.zeeblo.com/mybb/stats.php
Username: testacc
Password: testacc
thanks harmor I will use that. But I think you missunderstood my original question. Im trying to block the stats displayed at the bottom of the Index page.
Oh, sorry Leon

If you understand my code edits then you can edit the index.php.

I'll start working on it just incase you don't
Are you sure it wasn't cache'd Toungue Try this
// Get Forum Statistics
if($mybb->settings['showindexstats'] != "no" && $mybb['uid'] != "0")
{
this
// Get Forum Statistics
if($mybb->settings['showindexstats'] != "no" && $mybb['usergroup'] != "0")
{
this
// Get Forum Statistics
if($mybb['uid'] != "0")
{
if($mybb->settings['showindexstats'] != "no")
{

... code in between

}
}
// Get Forums
or this
// Get Forum Statistics
if($mybb['usergroup'] != "0")
{
if($mybb->settings['showindexstats'] != "no")
{

... code in between

}
}
// Get Forums
One of those has got to work!
Pages: 1 2