Article

Drupal 7 Views - How to show a global text message publicly but hidden for logged in users

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 :

  1. 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 
     
  2. Next, you need to install Views Role Based Global Text module
    https://www.drupal.org/project/views_role_based_global_text
     
  3. 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.

  1. Under the advanced settings in your View, Add a Global Text are under No Results Behaviour, then
     
  2. 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.

See also related article  Drupal 7 Views - How to restrict views page and contents by taxonomy term role, but provide a global text message publicly

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.