By wpanssi on
Is there a function to check whether the user is administer? I use the following snippet and it seems to work, but I think there might be more elaborative way of doing this..
global $user;
$admini=false;
foreach($user->roles as $role){
if($role=='admin')
$admini=true;
}
Comments
Use the php search function
$admini = (array_search('admin', $user->roles) === false );
Note that is must be '=== false', because if it returns a 0 it is a admin too...