With this code I can verify that the user is registered to the forum.
chdir('../../discussioni'); // path to MyBB
define("IN_MYBB", 1);
require './global.php';
if($mybb->user['uid']){
// Fai qualcosa
}else{
echo "<p>Per accedere a questa pagina devi essere registrato e loggato</p>";
}
But, what I have to do for making to access an external page of the forum alone the administrator?
You can seperate via groups, for example:
if($mybb->user['usergroup'] == 4){
// Do things only Admins can do
}else{
// Is a normal user
}
You can change the
4 to whichever group you want. To add more groups, do the following:
if($mybb->user['usergroup'] == 4 || $mybb->user['usergroup'] == 5 || $mybb->user['usergroup'] == 6){
(2009-01-03, 03:04 PM)Tom.M Wrote: [ -> ]You can seperate via groups, for example:
if($mybb->user['usergroup'] == 4){
// Do things only Admins can do
}else{
// Is a normal user
}
You can change the 4 to whichever group you want. To add more groups, do the following:
if($mybb->user['usergroup'] == 4 || $mybb->user['usergroup'] == 5 || $mybb->user['usergroup'] == 6){
Thanks, I Knew it. Is there any other way?
I haven't tried it this way, I think you can use:
if($mybb->usergroup['cancp'] == 1 && $mybb->user['uid']){
// This user can access the ACP
}else{
// This is either a guest or normal user
}
Test before using it a production environment
This checks whether the user can access the ACP (and therefore, an Administrator) and a user is actually logged in... I guess if this works it probably would be the best way...
Thanks for the help.
I have also found this function. Problem resolved.
if($mybb->user['uid']){
if (is_super_admin ($mybb->user['uid'])) {
echo 'Ok';
}
}