Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.
- Index
- » MetaMod
- » MetaMod General Support
- » Need to Force Login After Certain...
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.
Re: Need to Force Login After Certain Time or Clicks
Hi,
(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
- Index
- » MetaMod
- » MetaMod General Support
- » Need to Force Login After Certain...
Board Info
- Board Stats:
- Total Topics:
- 1689
- Total Polls:
- 6
- Total Posts:
- 5943
- Posts this week:
- 2
- User Info:
- Total Users:
- 7643
- Newest User:
- ulmer60661
- Members Online:
- 1
- Guests Online:
- 172
- Online:
- ulmer60661
Forum Legend:
Topic
New
Locked
Sticky
Active
New/Active
New/Locked
New Sticky
Locked/Active
Active/Sticky
Sticky/Locked
Sticky/Active/Locked