By kathc on
A new site (Drupal 6) will have members signing up, and one of our benefits requires a membership number. I'd like to have users sign up, validate their email, and then receive a welcome email with a membership number with a prefix and an auto incremented value (which may also be printed on a card).
We may someday have enough going on to implement something like CiviCRM, but for now, i just want a number. Is there any easy way to do this?
Comments
Any reason not to simply use
Any reason not to simply use their drupal user id?
The powers that be would like
The powers that be would like it to have a prefix of the month joined (i.e. if I signed up today, I could be 0904005 instead of user/5).
A couple of approaches, you
A couple of approaches, you could in the standard email sent add a string like !MEMBER_ID then implement hook_mail_alter() so replace the string with the desired value. Details depend on what options you have set for people who sign up.
Or you could use the rules module to generate the welcome message, for event pick "User account has been created", for condition add one with
return TRUE;for the PHP code (it's always true). Then add an action for " Send a mail to a user". Set from address and subject as desired. In the message you can use something like<?php print format_date($account->created, 'custom', 'mdY') . sprintf('%08', $account->uid); ?>to generate the member id (it forms the member id from the date the account was formatted as month day year (ex 04142009) followed by the user id, up to 8 digits long, zero filled).thank you
Thanks very much for your advice. I've spent a good chunk of my day reading and working with Rules, and I can see many uses for this! I haven't quite got it working yet, but I'm starting to see where I'm going.