Welcome to Geeklog, Anonymous Thursday, March 28 2024 @ 07:20 am EDT

Geeklog Forums

Welcome email


Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany

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

 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany

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

 Quote

Status: offline

etegration

Forum User
Full Member
Registered: 02/20/02
Posts: 179

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
An updated version of this hack (for Geeklog 1.3.8 / 1.3.8-1) is now available in the downloads section. bye, Dirk
 Quote

Paul

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
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
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.
Make sure the plugins directory and the welcome_email.txt file are readable for the webserver. bye, Dirk
 Quote

Paul

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
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
Quote by Paul:It still sends out a preformatted message and I can\'t figure out how this is happening.
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
 Quote

Paul

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
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
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
 Quote

Paul

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
 Quote

Paul

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
 Quote

Status: offline

emagin

Forum User
Regular Poster
Registered: 08/05/03
Posts: 92
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
 Quote

Status: offline

1000ideen

Forum User
Full Member
Registered: 08/04/03
Posts: 1298
Is this hack still valid for 1.4.0sr2?
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
Quote by 1000ideen: Is this hack still valid for 1.4.0sr2?

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
 Quote

All times are EDT. The time is now 07:20 am.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content