Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.
- Index
- » MetaMod
- » MetaMod General Support
- » Showing module only after registration
Showing module only after registration
Re: Showing module only after registration
Yes, you can do this using the recipes on this page, combined with a little extra setup for detecting logged in users:
http://www.metamodpro.com/metamod/recip … odule-once
If you set up your MetaMod with access for registered users only, then that takes care of that side of it. Then use the following PHP inside the MetaMod to make it show only once for a given user:
$c = JRequest::getInt('SeenIt', 0, 'cookie');
if ($c) return; /* if cookie was set, don't show anything, else... */
setcookie( 'SeenIt', 1, time()+60*60*24*365*10, '/' ); // 10 year cookie
return 101; /* return module 101, but only the first time */
// change the "101" to be the module id of the module you want to display once.
Re: Showing module only after registration
Actually Tim I realised that you wanted the module to be shown for the rest of the session after registration, but not for subsequent logins. This is a little more challenging. It's difficult to detect when someone is bouncing through from the registration event itself in order to trigger the module to start to display, so I'd suggest that we use the mechanism that detects for how long someone has been registered. We could try this:
If user has been registered for less than 15 minutes and is logged in, then set a session variable.
- if the session variable is set, then show the module.
The session variable automatically expires at the end of a "Session" i.e. there's a timeout you can set in Joomla for how long a session lasts for after the user does their last action on the site.
So it could look like this in PHP:
if ($user->id > 0 and $core_genius->check("minutessinceregistration <= 15")) {
$_SESSION['show_reg_message'] == true;
}
if (isset($_SESSION['show_reg_message']) and $_SESSION['show_reg_message'] == true) {
return XXX;
// replace XXX with module id of module to show
}
Hopefully that will do the right thing. The only downside is that if the user logs out and in during that 1st 15 minutes then they will see the message in both sessions, but hopefully this will not be too much of a disadvantage.
Cheers,
Stephen
Re: Showing module only after registration
Hi Stephen,
Thanks for your help but unfortunately it does not show.
What I have done:
- Moduel to show and metamod module both on registered
- Added the code you mentioned
- Added the module nr on the XXX
I have done a test account but now module is show when I register.
Any clue why?
Tim
Re: Showing module only after registration
Oops, yes, I can see why. I put in a stray "=". Replace the 2nd line with this. Note the single "=" instead of double "==".
$_SESSION['show_reg_message'] = true;
Sorry about that. I just tested the revised version and it seems to work for me.
Stephen
Re: Showing module only after registration
Hi Stephan,
Yes it is showing up now. The only things is that it does not disappears afet 15 minutes, everytime I log in it is showen again even after 15 minutes. Next to this it is also shown when people have registered 20 days ago.
This is the recipe I am using:
if ($user->id > 0 and $core_genius->check("minutessinceregistration <= 15")) {
$_SESSION['show_reg_message'] = true;
}
if (isset($_SESSION['show_reg_message']) and $_SESSION['show_reg_message'] == true) {
return 206;
// replace XXX with module id of module to show
}
Thanks
Tim
Re: Showing module only after registration
Hi Tim,
I'm surprised it's not working properly... can't imagine how it can possibly show up for people who have been registered for 20 days.
Could you try the following in the PHP box, then log in as one of those users who have been registered for more than 20 days and see what the front end tells you?
echo "minutes since registration: " . $core_genius->info("minutessinceregistration");
Thanks,
Stephen
- Index
- » MetaMod
- » MetaMod General Support
- » Showing module only after registration
Board Info
- Board Stats:
- Total Topics:
- 1689
- Total Polls:
- 6
- Total Posts:
- 5943
- Posts this week:
- 2
- User Info:
- Total Users:
- 7642
- Newest User:
- mary26
- Members Online:
- 0
- Guests Online:
- 206
- Online:
- There are no members online
Forum Legend:
Topic
New
Locked
Sticky
Active
New/Active
New/Locked
New Sticky
Locked/Active
Active/Sticky
Sticky/Locked
Sticky/Active/Locked