Number of days since first registration

(5 votes, average 4.20 out of 5)

This recipe can easily be customised to show people new modules based on how many days they have been registered. You may want to progress your registered users through a rolling programme of advertising / instruction etc. e.g. for the first week after they register show one module, then another for the next week, and another after that.

With JomGenius

This technique is available from MetaMod 2.4 onwards.
if ($user->id > 0) { // ensure that there's a logged in user
  $days = $core_genius->info( 'days_since_registration' );
  if ($days >= 21) return WWW; // for all users reg for 3 weeks or more
  if ($days >= 14) return XXX; // for all users reg for 2 weeks or more
  if ($days >=  7) return YYY; // for all users reg for 1 week or more
  return ZZZ; // user has been registered from 0-7 days
}
// replace WWW-ZZZ with the module id numbers to return
// note: you can replace days_since_registration with minutes_since_registration

Pre-JomGenius

If you have MetaMod 2.4 or more recent, try the "JomGenius" version instead of this one.
if ($user->id > 0) { // ensure that there's a logged in user
  $days = (int)((time() - strtotime( $user->registerDate )) / (24*60*60));
  if ($days >= 21) return WWW; // for all users reg for 3 weeks or more
  if ($days >= 14) return XXX; // for all users reg for 2 weeks or more
  if ($days >=  7) return YYY; // for all users reg for 1 week or more
  return ZZZ; // user has been registered from 0-7 days
}
// replace WWW-ZZZ with the module id numbers to return