1
natxocc
How to check if user is admin
  • 2005/2/1 21:44

  • natxocc

  • Just popping in

  • Posts: 19

  • Since: 2005/1/23


I think the the correct code is:

if ($xoopsUserIsAdmin)
{
...



but it doesn't work

I wanted to use it in php file not in template.

Is there other option to do this?

2
natxocc
Re: How to check if user is admin
  • 2005/2/1 22:17

  • natxocc

  • Just popping in

  • Posts: 19

  • Since: 2005/1/23


I found it!


if ($xoopsUser)
{
if ($xoopsUser->isAdmin(-1))
{
...

3
jdseymour
Re: How to check if user is admin

Here is a snippet out of kernel/user.php Maybe it will help:

/**
     * Is the user admin ?
     *
     * This method will return true if this user has admin rights for the specified module.
     * - If you don't specify any module ID, the current module will be checked.
     * - If you set the module_id to -1, it will return true if the user has admin rights for at least one module
     *
     * @param int $module_id check if user is admin of this module
     * @return bool is the user admin of that module?
     */
    
function isAdmin$module_id null ) {
        if ( 
is_null$module_id ) ) {
            
$module_id = isset($GLOBALS['xoopsModule']) ? $GLOBALS['xoopsModule']->getVar'mid''n' ) : 1;
        } elseif ( 
intval($module_id) < ) {
            
$module_id 0;
        }
        
$moduleperm_handler =& xoops_gethandler('groupperm');
        return 
$moduleperm_handler->checkRight('module_admin'$module_id$this->getGroups());
    }



4
natxocc
Re: How to check if user is admin
  • 2005/2/2 19:21

  • natxocc

  • Just popping in

  • Posts: 19

  • Since: 2005/1/23


thanks!

it was useful!!

Login

Who's Online

286 user(s) are online (181 user(s) are browsing Support Forums)


Members: 0


Guests: 286


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