MyBB Community Forums

Full Version: Require login to view custom .php page
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
//Guests are not allowed to view the page

if ($mybb->user['usergroup'] == 1)
{
    error_no_permission();
} 

You can use this to block the page from guests (need to login)
(2015-01-05, 03:48 PM)ShadowOne Wrote: [ -> ]
(2015-01-05, 03:44 PM).m. Wrote: [ -> ]^ fine. I don't want to argue. BUT tested it once again on MyBB 1.8.3


<?php
define("IN_MYBB", 1);
require_once "global.php";

if (in_array($mybb->user['usergroup'] , array(1,7))) error_no_permission(); 

// Rest of code
echo 'MyBB';
?>

this time it worked Smile

(2015-01-05, 05:23 PM)PhantomD Wrote: [ -> ]
//Guests are not allowed to view the page

if ($mybb->user['usergroup'] == 1)
{
    error_no_permission();
} 

You can use this to block the page from guests (need to login)


Have to mark as unsolved Sad
I've just attempted to view the page with a test profile and not my admin one... access is denied to him too
admin can access, guests and other groups no
If you are use a MyBB 1.8.x version you could try this:

<?php
define("IN_MYBB", 1);
 
require("global.php");
 

if (is_member("1,7")){ //Insert usergroup IDs to deny them permissions to enter page
    error_no_permission();
} else {
    add_breadcrumb("YourCustomPage");
    eval("\$your_custom_page = \"".$templates->get("your_custom_page")."\";");
    output_page($your_custom_page);
}
?>
(2015-01-05, 07:45 PM)SvePu Wrote: [ -> ]If you are use a MyBB 1.8.x version you could try this:


<?php
define("IN_MYBB", 1);
 
require("global.php");
 

if (is_member("3,4,6")){ //Insert usergroup IDs to give them permissions to enter page
    add_breadcrumb("YourCustomPage");
    eval("\$your_custom_page = \"".$templates->get("your_custom_page")."\";");
    output_page($your_custom_page);
} else {
    error_no_permission();
}
?>

i keep getting the "no permissions" message with test account... it's mybb 1.8.3
I have edited code ... pls try again

=> http://community.mybb.com/thread-165195-...pid1129878
(2015-01-05, 07:58 PM)SvePu Wrote: [ -> ]I have edited code ... pls try again

=> http://community.mybb.com/thread-165195-...pid1129878

Nothing.
I seriously can't understand why i keep getting the no permission error..

EDIT: the situation is the following

-with Admin profile i can see each page including custom ones
-with guest profile i get no permission message on each page (force login option enabled in settings)
-with registered user (test profile) i can see the board but get no permission message on custom pages..
With this custom page code guests and banned users have no permissions to view the page. All other usergroups can enter page.

<?php
define("IN_MYBB", 1);
 
require("global.php");
 

if (is_member("1,7")){ //Insert usergroup IDs to deny them permissions to enter page
    error_no_permission();
} else {
    add_breadcrumb("YourCustomPage");
    eval("\$your_custom_page = \"".$templates->get("your_custom_page")."\";");
    output_page($your_custom_page);
}
?>
(2015-01-05, 08:05 PM)SvePu Wrote: [ -> ]With this custom page code guests and banned users have no permissions to view the page. All other usergroups can enter page.


<?php
define("IN_MYBB", 1);
 
require("global.php");
 

if (is_member("1,7")){ //Insert usergroup IDs to deny them permissions to enter page
    error_no_permission();
} else {
    add_breadcrumb("YourCustomPage");
    eval("\$your_custom_page = \"".$templates->get("your_custom_page")."\";");
    output_page($your_custom_page);
}
?>

nothing, i got another time the no permission message with test user
do you have the default mybb usergroup settings ( guest = gid1 ... etc)
(2015-01-05, 08:19 PM)SvePu Wrote: [ -> ]do you have the default mybb usergroup settings ( guest = gid1 ... etc)

yes i have Sad
Pages: 1 2