MyBB Community Forums

Full Version: Can I restrict a page to be accessed only from within the forum?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello ALL,

I created a web page that performs a query on some custom fields on my forum user database and shows the results.

I have an icon for that page on the top menu of my forum but I would like to prevent that page from being accessed by guests or by typing directly the URL an bypassing the forum.

Any idea on how can I do that?

Thanks in advance.
In the PHP page you could try
if (mybb->user['gid'] != 1) {
			error_no_permission();
}
(2009-08-17, 07:47 PM)Polarbear541 Wrote: [ -> ]In the PHP page you could try
if (mybb->user['gid'] != 1) {
			error_no_permission();
}

Thanks... I tried that based on another post's response but it looks like the code is not being able to access the mybb->user['gid'] var. I tried an echo with that and got no results...

Any hint?

tks.
Same here.... O_o

I need to use the same function thingy for a plugin. Sad

EDIT: I'm looking into this Toungue

Try:
      $mybb->user['usergroup'];
Try this (as guests have no uid):

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

error_no_permission();

}
hang on a minute, in the earier post, PB said that you should try this:

(2009-08-17, 07:47 PM)Polarbear541 Wrote: [ -> ]In the PHP page you could try
if (mybb->user['gid'] != 1) {
			error_no_permission();
}

That won't work because it will check if the gid is NOT 1:
!= 1
If it doesn't equal 1, then throw the no permission error...

Try changing that to
== 1
You have a typo. It's $mybb->user not mybb->user. You missed the $.

Also use this code:
if ($mybb->user['uid'])
            error_no_permission();
That should do it.
Thanks to all.

To test that, I am putting an "echo $mybb->user['uid']" on the web page I am calling but I dont get anything... it looks like the page is not "receiving" the mybb vars...

The code I added to my page is below. I can see the "-" sign but I dont get nothing for the user variable...

echo "-";
echo $mybb->user['uid'];

Any hint?
Did you add it after the global.php include?
(2009-08-18, 08:19 PM)labrocca Wrote: [ -> ]Did you add it after the global.php include?

Beeing a noob definitelly sucks... I did not have a global.php include.

I included it, defined IN_MYBB and now its working!

Great!

tks!