1
dujour
Make own page only acces by admins
  • 2005/5/26 8:43

  • dujour

  • Just popping in

  • Posts: 3

  • Since: 2005/5/26


Is there some code to make a page only accesble for admins?

2
wtravel
Re: Make own page only acces by admins

You can have a look at one of the modules, usually I take mylinks as an example. When you look at the index.php file in de admin folder, you will will see that a header.php file is included. I believe in that file you will find how you can insert a code to make the page accessible by admin only.

I wish I could be more specific but I am not at home right now so I cannot look into the files

3
dujour
Re: Make own page only acces by admins
  • 2005/5/26 9:50

  • dujour

  • Just popping in

  • Posts: 3

  • Since: 2005/5/26


if ($xoopsUser && $xoopsUser->isAdmin($xoopsModule->mid())) {
$isadmin = true;
} else {
$isadmin = false;
}

Do you mean this code?

4
dujour
Re: Make own page only acces by admins
  • 2005/5/26 9:59

  • dujour

  • Just popping in

  • Posts: 3

  • Since: 2005/5/26


made a mistake now i have include cp_header.php it works fine but he says now that i have no premisons and when i'm logged in he doesen't show anything

5
Mithrandir
Re: Make own page only acces by admins

Where is the file located?

cp_header.php is only to be included from modules/[name]/admin

If you need to put access restrictions on pages in the modules/[name]/ folder, you should use code similar to your previously mentioned
if ($xoopsUser && $xoopsUser->isAdmin($xoopsModule->mid())) {
$isadmin true;
} else {
$isadmin false;
}

6
wtravel
Re: Make own page only acces by admins

That was indeed the code I was referring to , so if you would like to redirect the visitor when he/she is not the admin of this module, you could add a redirect function:

if ($xoopsUser && $xoopsUser->isAdmin($xoopsModule->mid())) {
$isadmin true;
} else {
$isadmin false;
->...
add redirect_header function and message here...<-
exit();
}

Login

Who's Online

242 user(s) are online (177 user(s) are browsing Support Forums)


Members: 0


Guests: 242


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits