Greetings everyone!

Here's my situation: Under Configuration > Workflow > Rules I have set up a rule that redirects an anonymous user to the log in page if the user views a node of a certain content type (that content type is "portfolio"). This rule is working just as I want it to. If a user clicks on a link to a portfolio node the user goes back to the log in page with a message explaining that the user must log in to view the content. Once authenticated, the user is sent back to the page that was trying to be accessed. Hurray!

This is what my rule looks like.

  • Event: Content is viewed
  • Conditions: User has role of "anonymous", Content is of type "portfolio"
  • Actions: Page redirect to log in, Show message "You must log in to view this content."

Here's my problem: When an anonymous user is using the search function the user is sent back to the log in page whenever any portfolio nodes are being returned in the search. If 4 portfolio nodes are returned on the search the user will be sent to the log in page with the message "You must log in to view this content" displayed 4 times. I know there are modules out there that will hide content that a user is restricted from viewing (node access) but my clients don't want to use that. My clients want the users to see links to content they can't access as this will give them incentive to create an account.

Here's my question: What do I have to do so that anonymous users can see search results containing portfolio content without forcing them to a log in page? I would like them to see the results and if they decide to click on a portfolio link they will be sent back to the log in screen as usual.

My best guess is that when Drupal is conducting a search each piece of content is being viewed individually. This is triggering my "content is viewed" event mentioned above. I'm not sure if I need to refine my rule or implement something else entirely. Please help!

Comments

abrownedc’s picture

I was able to eventually resolve the issue with some help from a user on another forum.

http://drupal.stackexchange.com/questions/77277/how-to-set-rules-event-for-content-is-viewed-from-excluding-teaser-view