Subject: Welcome email

Posted on: 01/06/02 05:20am
By: Dirk

Sometimes, the welcome mail that Geeklog sends to new users (and which contains their username and password) is just not flexible enough. E.g. you may have some sort of promotion running and want to point new users to it. Or you just want to tell them more about the site in that mail.

Well, here is a simple hack for that problem ...

The idea is to use Geeklog's template class on a text file. This allows the use of variables, e.g. for the username and password as well as for the site name and URL. Other than that, it's just a simple text file you create which contains the email you want to send to new users.

All you need is a modified version of the function emailpassword() from users.php and the actual email file, which I put into /path/to/geeklog/plugins/welcome_email.txt

When the text file does not exist, Geeklog will send the standard email again. So you can simply delete (or rename) the file if you don't need it temporarily.

Have fun.

bye, Dirk


Oops ...

Posted on: 08/06/02 01:42pm
By: Dirk

I originally suggested putting the welcome text into the language directory. However, that is not a good place since it will then show up in your display preferences where you can select it as a language file ... So I've changed the story and the replacement emailpassword() function to use the plugins directory instead.

bye, Dirk


Useful!

Posted on: 11/06/02 02:04am
By: etegration

This is really useful! Thanks!

Re:Welcome email

Posted on: 19/08/03 06:14am
By: Dirk

An updated version of this hack (for Geeklog 1.3.8 / 1.3.8-1) is now available in the downloads section. bye, Dirk

Re:Welcome email

Posted on: 21/08/03 05:02am
By: Anonymous

I have set this up to the letter, and the message returned is still the standard one. Are there any special permissions required on directories for this to work? I have GL v1.3.8, have replaced the code in users.php and have put an amended welcome_email.txt file in the plugins directory as suggested. Any pointers would be appreciated. Thanks, Paul

Re:Welcome email

Posted on: 21/08/03 10:02am
By: Dirk

[QUOTE BY= Paul]I have GL v1.3.8, have replaced the code in users.php and have put an amended welcome_email.txt file in the plugins directory as suggested.[/QUOTE] Make sure the plugins directory and the welcome_email.txt file are readable for the webserver. bye, Dirk

Re:Welcome email

Posted on: 22/08/03 09:11am
By: Anonymous

I am still having troubles and it is not down to permissions! As a test, I have inserved your code in place of the existing emailpassword function in users.php but removed the whole \'If, else, end\' statements and replaced it with your code just in the \'If\' part. So no check is done for the text file, it should just execute the code: $template = new Template ($_CONF[\'path\'] . \'plugins\'); $template->set_file (array (\'mail\' => \'welcome_email.txt\')); $template->set_var (\'auth_info\', \"$LANG04[2]: $usernamen$LANG04[4]: $passwd\"); $template->set_var (\'site_name\', $_CONF[\'site_name\']); $template->set_var (\'site_url\', $_CONF[\'site_url\']); $template->set_var (\'username\', $username); $template->parse (\'output\', \'mail\'); $mailtext = $template->get_var (\'output\'); But even this is not sending the customised mail! It still sends out a preformatted message and I can\'t figure out how this is happening. Any Ideas please. This feature would be an excellent mod to my site if I can figure out whats wrong. Thx in adv, Paul

Re:Welcome email

Posted on: 22/08/03 09:39am
By: Dirk

[QUOTE BY= Paul]It still sends out a preformatted message and I can\'t figure out how this is happening.[/QUOTE] How are you creating a new user? When you create a new user from the Admin menu (i.e. admin/user.php) or when the user submission queue is enabled and you approve users from admin/moderation.php, then it\'s still sending out the old message. However, when new users register with the site via users.php?mode=new (and the user submission queue is off), then they should get the new message. bye, Dirk

Re:Welcome email

Posted on: 22/08/03 10:19am
By: Anonymous

I do have the submission queue turned on. Is there a way I can configure this to work the same way in this mode of operation please? Thx, Paul

Re:Welcome email

Posted on: 22/08/03 10:36am
By: Dirk

The code in function moderateusers() in admin/moderation.php is very similar to that of function emailpassword(). If you replace the part that starts with $mailtext = \"{$LANG04[15]}\\n\\n\"; and ends with $mailtext .= \"{$_CONF[\'site_url\']}\\n\"; with the if (file_exist ...) ... else ... block from the hacked emailpassword() function it should work (I think - haven\'t tested it). bye, Dirk

Re:Welcome email

Posted on: 22/08/03 10:47am
By: Anonymous

I have amended the moderation.php but it does look a little different from users.php It works apart from the mail message leaves the UserID blank. The password is mailed properly though. Is there an extra line I need to add to get the userID lookup? Thanks, Paul

Re:Welcome email

Posted on: 22/08/03 11:00am
By: Anonymous

OK I have fixed the username issue. Here is what I did: replace the section between first and last lines here in moderation.php: DB_change($_TABLES[\'users\'],\'passwd\',\"$passwd2\",\'username\',$A[\'username\']); if (file_exists ($_CONF[\'path\'] . \'plugins/welcome_email.txt\')) { $template = new Template ($_CONF[\'path\'] . \'plugins\'); $template->set_file (array (\'mail\' => \'welcome_email.txt\')); $template->set_var (\'auth_info\', \"$LANG04[2]: {$A[\'username\']}n$LANG04[4]: $passwd\"); $template->set_var (\'site_name\', $_CONF[\'site_name\']); $template->set_var (\'site_url\', $_CONF[\'site_url\']); $template->set_var (\'username\', $username); $template->parse (\'output\', \'mail\'); $mailtext = $template->get_var (\'output\'); } else { $mailtext = \"{$LANG04[15]}nn\"; $mailtext .= \"{$LANG04[2]}: {$A[\'username\']}n\"; $mailtext .= \"{$LANG04[4]}: $passwdnn\"; $mailtext .= \"{$LANG04[14]}nn\"; $mailtext .= \"{$_CONF[\"site_name\"]}n\"; $mailtext .= \"{$_CONF[\'site_url\']}n\"; } if (empty ($LANG_CHARSET)) { The problem with the username was fixed by putting {$A[\'username\']} in the code instead of $username Thanks for all your help. This is an excellent hack. Cheers, Paul

Re:Welcome email

Posted on: 07/09/03 02:47am
By: emagin

Paul, thanks for sleuthing that out. I\'m getting the email sent out, but there is an odd error. When the text email returns {auth_info} part, it adds an \'n\' between the username and password User Name: xxxxxxxxnPassword: xxxxxxxx

Welcome email

Posted on: 11/03/06 10:12am
By: 1000ideen

Is this hack still valid for 1.4.0sr2?

Welcome email

Posted on: 11/03/06 10:24am
By: Dirk

[QUOTE BY= 1000ideen] Is this hack still valid for 1.4.0sr2?[/QUOTE]
It has been integrated into Geeklog for a while now (since 1.3.10). The file has to be placed in the "data" directory now, but other than that it works as described above.

bye, Dirk

Geeklog - Forum
https://www.geeklog.net/forum/viewtopic.php?showtopic=21130