Panels and Drupal 6: Showing a panel item for a user if they have all required roles

Panels visibility rulesPanels is a powerful Drupal module that turns the CMS into a powerhouse for user experience.  If you have not used Panels you will eventually if you want to do anything complex with Drupal.  It seems overwhelming when you start using it but it quickly becomes your best friend.

I'd like to reflect on a nugget of knowledge that wasn't particularly obvious to me when I was developing a Panels page.  Here's my scenario:

  • The user is filling out a completion-based system where they create nodes
  • I wanted a notification message when the user completed all of the steps

I use Rules to assign new roles to users as they complete steps of the process.  It's cumbersome to have a Rule fire off after every save to check for final completion.  If that happened I'd also need yet another role that says "they've completed the entire process".  Instead, using Panels I can examine the user's current roles with visibility rules (different than rules from the Rules module... confusing, isn't it?).  

In the screenshot with this post you'll see the interface for adding visibility rules.  Here are the fundamentals of these visibility rules that I'd like to convey with this post:

  • Each separate visbility rule must pass for the item to be shown (logical AND)
  • If you select multiple roles within the rule they function as a logial OR (any of the roles can make that separate rule true)
  • This means between rules you have a logical AND comparison and within each rule itself you have a logical OR comparison (at least when you're doing role-based visibility)

I was able to craft a panel item that used the logical AND knowledge to check if the user had three different roles and to show the completed panel item.