Drupal 7 Views - How to show a global text message publicly but hidden for logged in users
Such a scenario might include cases when you need to show a public message intended for users to signup and register to avail restricted contents, such as:
- Register to View Contents
- Become a Member to Download Contents
- and similar use cases
Steps to restrict your Views page and contents :
- Configure your Views to restrict the page and contents to the public (hiding it from public view, accessible only to registered users/members or certain roles). See also article to do this here http://www.knowledgebase.ibuild.ph/drupal-7-views-how-restrict-views-page-and-contents-taxonomy-term-role-provide-global-text-message
- Next, you need to install Views Role Based Global Text module
- Install and configure. There is a "Role" setting while entering text either on header or footer.
No Results Behavior
Since you will need the same public global text message hidden upon log-in, you will need to set this viewable only for anonymous users/role.
- Under the advanced settings in your View, Add a Global Text are under No Results Behaviour, then
- Select only anonymous user. This will make this global text message appear publicly even with the Views content hidden, and the same global text message disappear when the user is already logged in.