Over the past few weeks I've been working away on the Nevada Boys' State website. It is a pretty cool site if I do say so myself. The delegates log in and complete things like the pre-program survey and submit legislation. Of course it is a Drupal site. Using Taxonomy Access Control pages are created for parents, staff or delegates. However parents and staff can look at the delegate pages. This is fine but there is some customization done on the page that shows the current user's email and reports that it's the "Delegate's email account".
It is a simple problem to solve and a quick trip to the Drupal site gave me the pieces to put together the following code that shows a note for anyone who logs in and views a Delegate page but doesn't have the role of Delegate. (Delegate has been changed in this code to MyRole).
#000000">#0000BB"><?php
#007700">global #0000BB">$user#007700">;
#0000BB">$approved_roles #007700">= array(#DD0000">'MyRole'#007700">);
if (#0000BB">is_array#007700">(#0000BB">$user#007700">->#0000BB">roles#007700">)) {
if (#0000BB">count#007700">(#0000BB">array_intersect#007700">(#0000BB">$user#007700">->#0000BB">roles#007700">, #0000BB">$approved_roles#007700">)) > #0000BB">0#007700">) {
print #DD0000">''#007700">;
} else {
print #DD0000">'<strong>You are viewing a page that is intended for MyRole but you are not logged in as a MyRole. You can view this page but please make sure a MyRole accesses this page to complete their tasks from their own account.</strong>'#007700">;
}}
#0000BB">?>