0

In Drupal 7, I need to create a view of member-only nodes. They're all of a certain type. This type—and I've already set that up with role-based access control—can only be seen by logged in users.

Now, I can create a view called Member Area that shows these nodes, and make it accessible only to logged in users (through the View access control), but when I create a menu entry for that view, the link obviously disappears when the user isn't logged in.

What I need is a link that points to a "please log in" text (could be on a static page, whatever) when the user isn't logged in. If the user then logs in, I want to display the view which shows only the restricted content.

Giving a specific example, I currently have this. The block is conditionally shown in the sidebar only on the page called Member Area. The page displays the static You are not logged in… text.

Once the user logs in, I want to show them the view of restricted content:

The horrible kludge that I use now is that I link the user to another view in the user menu, but that's really bad UX.

Can I set this up somehow?

2

What I did was quite simple:

  • Create the view normally, without access restrictions and link it to the menu.
  • Make sure the nodes themselves can only be seen by logged in users.
  • Create a No results behavior text that tells users to log in.
  • Show the login block only on the view's page.
1

I believe you're looking for https://drupal.org/project/r4032login

In addition to that, this module: https://drupal.org/project/menu_item_visibility will allow you to set the menu item to be visible to anonymous users as well even though they can't access its content. when they click on it they're redirected to login.

  • Ah, I found a workaround for my situation (see my answer), but those modules you mention would both work great. Thank you. – slhck Sep 20 '13 at 18:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.