in PHP - how would I show an ADMIN link only for ADMIN users

spit

Joined: 2007-08-20
Posts: 14
Posted: Tue, 2007-11-06 10:39

I'm using a few PHP pages outside my G2 application, which rely on the G2 embed functionality to work.

I'm trying to only display the admin link when admin users are logged-in, but cannot find a way in PHP to do include in an IF statement along the lines of:

if(youareanadminuser) {showlink};

Thanks

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Tue, 2007-11-06 18:31

please see the user specific variables at documentation -> development -> themes -> variables.

--------------
Documentation: Support / Troubleshooting | Installation, Upgrade, Configuration and Usage

 
spit

Joined: 2007-08-20
Posts: 14
Posted: Thu, 2007-11-08 08:53

Unfortunately for me - that documentation is written around doing the above in smarty, whereas I need to do it in PHP.

So the smarty docs say something like:
{if $user.isAdmin}
something
{/if}

But if I try what I think is the equivalent in a PHP page outside of G2 it doesn't work:
if ($user.isAdmin){
something
}

 
spit

Joined: 2007-08-20
Posts: 14
Posted: Tue, 2010-03-02 09:55

I had the same issue and found the result on the forum elsewhere - do this in PHP:

Quote:
list ($ret, $isAdmin) = GalleryCoreApi::isUserInSiteAdminGroup();
if ($ret) {
return array($ret, null);
}
if ($isAdmin) { // admin user so show 'set-up' button
// code here you want to use/display
}

Thought I'd post it as most questions re. $isAdmin are based around Smarty, with little PHP solutioning.