MyBB Community Forums

Full Version: force login on custom pages through PageManager?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I know I've seen it before on SOME site SOMEWHERE, but just cannot find it this AM.

Have a couple custom pages within Page Manager, but I can link to them without being logged in, and I'd really like to lock them down to only users that are logged in. Like to show the standard message:

You are either not logged in or do not have permission to view this page. This could be because one of the following reasons:
You are not logged in or registered. Please use the form at the bottom of this page to login.
You do not have permission to access this page. Are you trying to access administrative pages or a resource that you shouldn't be? Check in the forum rules that you are allowed to perform this action.
Your account may have been disabled by an administrator, or it may be awaiting account activation.
You have accessed this page directly rather than using appropriate forms or links.
You should use error_no_permission() function at the begiinning of page, for example together with uid/usergroup conditional.
if(!$mybb->user['uid'])
{
    error_no_permission();
}
(2013-11-07, 01:22 AM)Destroy666 Wrote: [ -> ]You should use error_no_permission() function at the begiinning of page, for example together with uid/usergroup conditional.
if(!$mybb->user['uid'])
{
    error_no_permission();
}

You had me up until you said "together with uid/usergroup conditional.
Basically, on my Custom page in PageManager, all it is is a straight HTML form that I have submitted and I collect the responses.

I don't have access to any PHP pages, but I do have access to my Template files and can change them, if necessary.
Well, as you said yourself, you use HTML-only pages. HTML isn't serverside language and checking for MyBB group is waaaaaaaay beyond its capabilities. So either convert your custom page to PHP (there are many simple tutorials and examples, just search), or you won't be able to do it.
I'm so happy I've done it at last.

Here's the code

<?php
if(!$mybb->user['uid'])
{
error_no_permission();
}
?>

I inserted it in my index template and it worked although I use a pluginto enable php code in templates.

Thanks for your time anyway. Just that you didn't understand me.