MyBB Community Forums

Full Version: Redirect on a custom page
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I created a custom page that i only wish to show to logged in users and another custom page that i only want to show to users in a certain usergroup. For the first page i added a check to see if the user is logged in

if($mybb->user['uid'] == 0){

}

But i would like something more gracefull like giving the error page with a login box instead so that if the user logs in she gets redirected to the custom page.

Thanks in advance for the help ^.^
For checking if its not logged in or is guest, you could also use:

if($mybb->user['usergroup'] == 1)
{
//Do something
}

And to show error message if a guest is not logged in, you could use code like this after checking with above setting query to check whether he is guest or not:

if($mybb->user['usergroup'] == 1)
{
error("You must login before you could see this page. Click <a href="member.php?action=login">login</a> 
or <a href="member.php?action=register">here</a> to to register.");
}
if(!$mybb->user['uid'])
{
	error_no_permission();
}

This is what I'd do. The error_no_permission() function throws the typical MyBB no permissions error, which has the login box embedded in it. It will also redirect the user back to the page after logging in.
That is a good way. But the only problem of no perms is that it won't display actual error message. That is why I use custom errors over certain pages.
(2012-03-27, 07:32 PM)Fábio Maia Wrote: [ -> ]
if(!$mybb->user['uid'])
{
	error_no_permission();
}

This is what I'd do. The error_no_permission() function throws the typical MyBB no permissions error, which has the login box embedded in it. It will also redirect the user back to the page after logging in.

Ah thanks a lot, this was exactly what i was looking for.
What crazy4cs seems more usefull for my rights problem. Will have to look into that. Big TY to both anyways ^.^
If the user doesn't have permissions to view the requested content then you should use error_no_permission(), error() if for custom error page (i.e: invalid thread, invalid profile, invalid action, 404 page, etc).
(2013-03-21, 12:24 AM)Omar G. Wrote: [ -> ]If the user doesn't have permissions to view the requested content then you should use error_no_permission(), error() if for custom error page (i.e: invalid thread, invalid profile, invalid action, 404 page, etc).
1 year strong bump? Shy
My bad, didn't checked the date.