Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.



Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.


Need to Force Login After Certain Time or Clicks

Need to Force Login After Certain Time or Clicks

I am putting together a realtor website here:  http://newhomesnowtexas.com/

I need to force the guest visitor to login or register after either 5 clicks or 2 searches.  I am not sure which would work and if I need to purchase one of the plugins to do this then please tell me which one. 

I also tried to use the free MetaMod to cause a module to not display on mobiles using the same parameters on a Joomla 2.5 installation but it is not working on this Joomla 3.3 installation for what ever reason, I do not know.  I have scoured the forums and release notes and tried a few options with nothing working.
Any suggestions would be helpful.

Beginner Modder
10 Posts
Administrator has disabled public posting

Re: Need to Force Login After Certain Time or Clicks


(A) forcing people to log in: that's an interesting scenario I haven't thought about before. I'm not sure the following is the best way to achieve it, but it's a first attempt at achieving your goal using Chameleon.

a - it's easy to detect search results pages and other page accesses. The "action" would be to increment a counter that's stored in the session. You could have 1 counter for page accesses and another for search results pages
b - another Chameleon rule would detect the counters and see if see if they exceed 5/2. If they did exceed it, Chameleon could redirect to a login page.
c - you could set up a login page as a menu item (e.g. on a hidden menu if not on the main menu), then use this as the destination page for redirections when people exceed the limit

So I'd set up the following rules in this order:

1 - detect the login page itself. If people are on that, then quit processing further rules (never want to stop people visiting here, and never want to count this towards their 5 page views)
[use GUI controls to select the menu item for the login page]

2 - detect logged in users. If found, quit processing further rules. We don't need to control logged-in users at all.
[use the GUI control for detecting logged-in users]

3 - detect any other pages you might want to allow people to see without counting towards their limit of 5. If found, quit processing further rules.
[use GUI control for selecting menu items or URLs of pages you want to allow]

4 - detect "search results" page type. If found, increment by session variable for search results by 1. If the page is any other type, increment page counter session variable by 1 (do this in the PHP block as it's easiest that way; see below). In the Succeed action, continue to next rule.

5 - detect if the session variable for page views = 5, or search results = 2. If found, redirect immediately to login page (menu item).
[use PHP snippet described below]

The PHP code required for rule 4 would be:

if ($core_genius->check("pagetype = searchresults")) $_SESSION['searchresultpages']++;
else $_SESSION['otherpages']++;
return true;

The PHP code required for rule 5 would be:

if ($_SESSION['searchresultpages'] >= 5 or $_SESSION['otherpages'] >= 2) return true;
else return false;

[B] Browser detection on Joomla 3.3 and MetaMod: this should work. Check the following:
a - if you turn on debug mode in MetaMod, do you get some output from the MetaMod on the page? You should. If you can see the output this shows that the MetaMod is published, assigned to a valid module position and to valid menu items (or all pages).
b - do you have any sort of caching enabled, e.g. system cache plugin or the caching in Global Configuration). Try turning all this off and see if that makes a difference. Basically the system cache plugin is incompatible with doing switching based on browser type (mobile) as it will only use 1 cache for everything irrespective of browser type.
c - if you are unsure about the PHP code you are using, please paste a copy of it into the forum here and I'll take a look at it for you. It may be something simple there.

Hope that helps,
Best regards,

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

3313 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
Total Topics:
Total Polls:
Total Posts:
User Info:
Total Users:
Newest User:
Members Online:
Guests Online:

There are no members online

Forum Legend:

 New Sticky