WP Sentry Enabled Navigation

Since we use WP Sentry for access control in a number of sites, one of the challenges we’ve faced is dealing with custom navigation bars which are WP Sentry compliant, meaning they don’t show links to pages the user isn’t supposed to know about.   Sentry would have blocked access to the page, but better that they didn’t see the link in the first place.   While this isn’t a “completely” Sentry compliant nav bar, you can see how we handled the need to hide an Administration page from a site except for those logged in and authorized to see it.  It’s likely there are other possibly better ways to handle the page ID and such, but this might help get you started!

<div id="navigation">
  <ul id="top-level">
    <?php
      global $WP_SENTRY;
      $current_user = wp_get_current_user();
      $current_user_id = $current_user->ID;

      $page = get_page_by_title( 'Administration' );

      //List all pages except administration
      wp_list_pages('sort_column=menu_order&title_li=&depth=3
           &exclude='. $page->ID );

      //we want to do the administration page separately and only show if
      //user is a member of the admin group and already logged in
      if ((current_user_can('level_0'))&&
           ($WP_SENTRY->user_is_allowed($current_user_id, $page->ID)))
      {
        echo "<li><a href=". get_permalink( $page->ID ) 
            . ">Administration</a></li>";                            
      }
    ?>
  </ul>
</div>