I run a site that provides training courses.
People on the site enter when their current qualifications expire in their profile. I would like them to receive an email on this date so they can be reminded to visit a site.

I am trying to use the Birthday module to do this.

However, as most people's qualifications expire in the future, the module doesn't seem to send out a reminder email (as it classes the entered date as a negative value).

Another problem is that because Birthdays is designed for birthdays, it sends out a reminder every year. So if a person’s qualification ends in 22nd October 2010, they will receive a reminder on 22nd October in 2008, 2009 and 2010.

Are there any work arounds for these problems?

Comments

maartenvg’s picture

I wouldn't recommend using Birthdays for this, because it has a lot of features and complexities that are not needed for the behavior that you describe. All queries and displays are designed on the fact that birthdays are recurring and lie in the past, while your expiration dates are in the future and are one time only.

Because you only need to send out an e-mail on the exact day set in the profile, your queries (and the rest of the module) can be a whole lot easier.

I have some suggestions, but they depend how many users you expect to have and whether you are able to create your own module.

big_smile’s picture

Thanks for your reply!

>I have some suggestions, but they depend how many users you expect to have and whether you are able to create your own module.

I would anticipate that such a system would have a large audience. There are many industries that provide training courses. However, people only book a place on these courses when their current qualification is about to expire. If their qualification is not yet to expire, then they do not book a course. By the time their qualification is ready for expiration, they have usually forgotten about the company where they got their qualification in the first place, thus causing that company to lose a sale.

Unfortunately, at this stage, I am not able to create my own module. However, I would dearly appreciate any suggestions you have, particularly those that relate to the usage of existing modules.

maartenvg’s picture

Status: Active » Closed (won't fix)

The easiest, but inefficient, solution I can think of is as follows:
- create a profile field of type 'date', remember the profile field id
- create a module which uses hook_cron() to retrieve all users with their date filled
- Then for each item you retrieve, unserialize the date, check if it is today.
- If so load the user
- check whether the user has already been sent an e-mail
- if not, send an e-mail.

So, something like this (warning, I haven't tested this in any way). Good luck!

/**
 * Set the profile field id pointing to the date field.
 */
define('PROFILE_REMIND_FIELD_ID', 1);

function profile_reminder_cron() {
  $result = db_query("SELECT u.uid, p.value FROM {profile_values} p LEFT JOIN {users} u ON p.uid = u.uid WHERE p.fid = %d AND u.status <> 0", PROFILE_REMIND_FIELD_ID);

  while ($row = db_fetch_object($result)) {
    extract(unserialize($row->value));
    if ($day == date('j') && $month == date('n') && $year == date('Y')) {
      $user = user_load('uid' => $row->uid);
      if (!isset($user->profile_reminder_sent)) {
        profile_reminder_mail($user);
        $user->profile_reminder_sent = 1;
        user_save($user, array('profile_remiinder_sent' => 1));
      }
    }
  }
}

function profile_reminder_mail($user) {
  // Some e-mailing stuff.
}