4

After an anonymous user viewed more than two or three articles, I want to redirect such user to the login/register page.

Any suggestions about how to make this work somehow?

2
  • enable statistics module. grab users ip from access log table count visits to nid's type and do a redirect Commented Feb 12, 2016 at 9:16
  • Nice thought :) i will work it out. cheers:)
    – NTT
    Commented Feb 12, 2016 at 9:20

2 Answers 2

5

Not sure if it is the only way to get this to work, and not sure if it is the most elegant way, but it should be doable as detailed below. It does not require any "custom" code, only some (often used) contributed modules.

Rule 1 - Count the visits

The Flag module can by used to flag (eg) articles, which itself can be done automatically (behind the scenes) via the Rules module (= 1st rule). To make the Flag module work for anonymous users also, you'll need to get the Session API involved. For more details on that, refer to:

Rule 2 - Trigger the redirect

With that, you have "a" counter (= number of articles flagged by a user) that you can use as a Rules Condition in a 2nd rule, whereas this 2nd rule can be triggered by a Rules Event like "after an article gets flagged". In that Rules Condition you just check if the counter exceeds your limit (= 2 in your case), then you perform the Rules Action (in the 2nd rule) which is to redirect to your login/register page.

2

You can take a look at the Node Limit module. Some more details about it (from its project page):

The Node Limit module allows administrators to restrict the number of nodes of a specific type that roles or users may create. For example, if a site has an "Advertiser" role that can create "advertisement" nodes, then the node limit administrator can restrict all users in that role to a specific number of nodes. He may also restrict users on a per-user basis.

Works well, but I don't have tested it with anonymous users.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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