xoops forums

CONFIQ

Just popping in
Posted on: 2006/6/3 13:28
CONFIQ
CONFIQ (Show more)
Just popping in
Posts: 21
Since: 2006/4/21
#1

$is_admin in PHP?

Hello all!
I know that i can check whatever user is admin/registered by smarty (ex: $xoops_isadmin/$xoops_isuser) but how do i check it with simple PHP?

$xoopsUser class gets those informations but if i write
$xoopsUser->getVar('uid'),
i get error that xoopsUser class is not loeaded! (if i'm not identified)

How do i check if user is registered or not?

Jan304

Official Support Member
Posted on: 2006/6/3 14:37
Jan304
Jan304 (Show more)
Official Support Member
Posts: 520
Since: 2002/3/31
#2

Re: $is_admin in PHP?

The lame method:

if ($xoopsUser != '') {
    
$uid $xoopsUser->getVar('uid');
}else{
    
$uid 0;
}
Oracle: I'd ask you to sit down, but, you're not going to anyway. And don't worry about the vase.
Neo: What vase?
[Neo turns to look for a vase, and as he does, he knocks over a vase of flowers, which shatters on the floor.]
Oracle: That vase.
Neo:...

Dave_L

XOOPS is my life!
Posted on: 2006/6/3 15:08
Dave_L
Dave_L (Show more)
XOOPS is my life!
Posts: 2277
Since: 2003/11/7
#3

Re: $is_admin in PHP?

Depending on the context, you might need:

global $xoopsUser;

m0nty

XOOPS is my life!
Posted on: 2006/6/3 15:18
m0nty
m0nty (Show more)
XOOPS is my life!
Posts: 3337
Since: 2003/10/24
#4

Re: $is_admin in PHP?

a better method would be:

if (is_object($xoopsUser)) {
    
$uid $xoopsUser->getVar('uid');
}else{
    
$uid 0;
}


but make sure $xoopsUser is defined as dave mentions above.

CONFIQ

Just popping in
Posted on: 2006/6/3 16:03
CONFIQ
CONFIQ (Show more)
Just popping in
Posts: 21
Since: 2006/4/21
#5

Re: $is_admin in PHP?

I'll check it out... thank you for your help!