Main menu

Show if content has Content Access set for a role but not other roles

02 May
Published by Mark W. Breneman

Yeah, this is a rather interesting snippet that has value to me, but does not seem like it would have value to others. Perhaps if a context trigger was based on this code.

The basic idea here is to check if staff role is the only role that has access to this content, if so do something.

<?php
$roles =content_access_per_node_setting('view',$object);
//dsm($roles);
if (in_array(4,$roles) and !in_array(19,$roles)){echo 'staff only';}
?>

Category 

Bookmark, Drupal

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.