Сниппет: показывать блок только определенной роли

Показывать блок ролям moderator и administrator

<?php
global $user;
$allowed = array('moderator','administrator');
$valid=FALSE;
foreach($user->roles as $role){
  if(in_array($role, $allowed)) {
    $valid=TRUE;
  }
}
return $valid;
?>

Не показывать блок ролям anonymous user и pingvin

<?php
global $user;
$notallowed = array('anonymous user','pingvin');
$valid=TRUE;
foreach($user->roles as $role){
  if(in_array($role, $notallowed)) {
    $valid=FALSE;
  }
}
return $valid;
?>

Comments

Anonymous's picture

re

That's well known that money makes people disembarrass. But how to act if one does not have money? The one way is to receive the loans and car loan.

Anonymous's picture

re

I frequently tried some essay papers and found out that this service is the satisfactory among them. I am return client for three years and find the work of this research paper company team expert.