|
How to Restrict Access to Custom Pages
|
|
02-18-2009, 07:55 PM
Post: #1
|
|||
|
|||
|
How to Restrict Access to Custom Pages
Hi
I'm following THIS tutorial to make custom pages for my MyBB forum, and it works fine. What I'd like to know is how to restrict the pages so they are not accessible by: a) certain usergroups b) guests Can anyone tell me the PHP needed to be added to my pages for this to happen? Thank you. |
|||
|
02-18-2009, 07:58 PM
Post: #2
|
|||
|
|||
|
RE: How to Restrict Access to Custom Pages
I'm not sure of the checks you'd have to do, but I know for the guest thing you can do:
PHP Code: if($mybb->user['uid'] == 0)Elite-Area / Last.FM Profile / PSN Name: XDaciD / Minecraft Map Progress: Coming Soon! [Staff note - No referral links] |
|||
|
02-18-2009, 08:34 PM
Post: #3
|
|||
|
|||
|
RE: How to Restrict Access to Custom Pages
To allow Admin only...
PHP Code: if($mybb->usergroup['cancp'])Admins And Super-Moderators... PHP Code: if($mybb->usergroup['cancp'] || $mybb->usergroup['issupermod'])Usergroup specific... PHP Code: if($mybb->user['usergroup'] == 3 || $mybb->user['usergroup'] == 5 || $mybb->user['usergroup'] == 6)Tom's example can be extended to: PHP Code: if(!$mybb->user['uid'] || $mybb->usergroup['isbannedgroup']) |
|||
|
02-19-2009, 12:02 PM
Post: #4
|
|||
|
|||
|
RE: How to Restrict Access to Custom Pages
These have been great replies, thank you.
|
|||
|
02-21-2009, 01:04 AM
Post: #5
|
|||
|
|||
RE: How to Restrict Access to Custom Pages This user has been denied support.
It's shorter code to make the error_no_permissions function first and continue as this will not need the else statment....
Example... Instead of this: Code: if($mybb->usergroup['cancp'] || $mybb->usergroup['issupermod'])You do this: Code: if(!$mybb->usergroup['cancp'] || !$mybb->usergroup['issupermod'])That's a cleaner method. New MyBB plugin is "My Awards 2.0".
|
|||
|
02-22-2009, 01:59 PM
Post: #6
|
|||
|
|||
| RE: How to Restrict Access to Custom Pages | |||
|
07-04-2009, 12:39 AM
Post: #7
|
|||
|
|||
|
RE: How to Restrict Access to Custom Pages
It does not work for me.I am trying to prevent guests from seeing the Portal, not just not being able to link to it. I have tried all of the following...I've put it in the header, in the body...what could it be? I don't believe it makes any sense. By the way, very new to PHP, but very excited.
The only change I have made to Portal is stripping all of the content between the header and the footer, and replacing it with widgets and feeds. First: <?php if($mybb->user['uid'] == 0) { error_no_permission(); } else { // Page Code } ?> Second: <?php if(!$mybb->user['uid'] == 0) { error_no_permission(); } else { // Page Code } ?> Third: <?php if($mybb->user['uid'] == 0) { error_no_permission(); } else { ?> // Page Code <?php } ?> Fourth: <?php if(!$mybb->user['uid'] == 0) { error_no_permission(); } else { ?> // Page Code <?php } ?> I've tried several variations of the above but to no avail. I would appreciate a nudge in the right direction. Thank you! |
|||
|
08-19-2009, 07:10 AM
(This post was last modified: 08-19-2009 07:43 AM by sMoKiE.)
Post: #8
|
|||
|
|||
|
RE: How to Restrict Access to Custom Pages
Hi there!
I tried the same thing but if I add on top of portal.php this code: Code: <?php Alright, problem fixed! Had to add this code after loading global.php! |
|||
|
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)
Search
Member List
Calendar
Help





This user has been denied support.
![[Image: 468x60_SF.gif]](http://supportforums.net/images/banners/468x60_SF.gif)