Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.

helpme

 

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

 

Showing module only after registration

Showing module only after registration

Hello,

Can someone help me with a recipe for showing a specific module only once. I want to show the module after someone has registered and logs in. When the comes back later it does not have to show anymore.

Thanks

tim
Beginner Modder
ranks
useravatar
Offline
13 Posts
Administrator has disabled public posting

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.

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

metamodguy
useravatar
Offline
3329 Posts
User info in posts
Administrator has disabled public posting

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

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

metamodguy
useravatar
Offline
3329 Posts
User info in posts
Administrator has disabled public posting

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

tim
Beginner Modder
ranks
useravatar
Offline
13 Posts
Administrator has disabled public posting

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

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

metamodguy
useravatar
Offline
3329 Posts
User info in posts
Administrator has disabled public posting

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

tim
Beginner Modder
ranks
useravatar
Offline
13 Posts
Administrator has disabled public posting

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

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

metamodguy
useravatar
Offline
3329 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1698
Total Polls:
6
Total Posts:
5944
Posts this week:
4
User Info:
 
Total Users:
5534
Newest User:
kaylee
Members Online:
0
Guests Online:
143

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