Written July 26, 2008 in Tutorial

PHPList is an awesome open source mailing list system, whose 30+ feature set includes:

  • double opt-in subscription mechanism
  • scheduling
  • RSS
  • list segmentation
  • click-tracking
  • attachments
  • bounce management

I use PHPList on a number of projects, and it’s a very powerful tool, although like any powerful tool, it can be “high maintenance”.

PHPList allows you to record arbitary details from your users at signup – i.e., their name, surname, favorite TV show, etc. You can then re-use these variables in your mail messages, by placing “placeholders” into the content. For example, “Hi [NAME], how was [TVSHOW] this week?” would translate to “Hi David, how was Heroes last week?”

There’s no built-in way to do this placeholder replacement on the subject line though. Since I have a need for this feature on Inspirational Journal, and somebody recently brought up the question on the forums, I’ve documented my process here.

Including PHPList user attribute placeholders on message subject lines

Assuming you’re using 2.10.5, there are two ways:

The easy (automatic) way

Download and uncompress the attached patch into your PHPList directory, and apply it by running:
[bash]patch -p1 < phplist_user_attributes_in_subject_2.10.5.patch[/bash]

the hard (manual) way

Edit admin/sendemaillib.php, look for the following code from line #723 to line #732:
[php]
if (!TEST) {
if ($hash != ‘forwarded’ || !sizeof($forwardedby)) {
$fromname = $cached[$messageid]["fromname"];
$fromemail = $cached[$messageid]["fromemail"];
$subject = $cached[$messageid]["subject"];
} else {
$fromname = ”;
$fromemail = $forwardedby['email'];
$subject = $GLOBALS['strFwd'].’: ‘.$cached[$messageid]["subject"];
}
[/php]
DIRECTLY AFTER this code (on line #733) paste the following:
[php]
// Funky Penguin Mod starts – variable substitution in the subject
if (is_array($user_att_values)) {
foreach ($user_att_values as $att_name => $att_value) {
if (eregi(“\[".$att_name."\]“,$subject,$regs)) {
$subject = eregi_replace(“\[".$att_name."\]“,$att_value,$subject);
}
}
}
// Funky Penguin Mod ends
[/php]
Now you should be able to use any user attribute variable in the subject line :)

download

Download: phplist_user_attributes_in_subject_2.10.5.patch.zip
Version: 0.1
Updated: July 27, 2008
Size: 0 bytes

Powered by Drain Hole

Related posts:

  1. WP-PHPList plugin updated to 2.10.9
  2. How to protect your website with htaccess, while allowing individual IP addresses unrestricted access
  3. WP-PHPList
  4. WP-PHPList plugin updated to 2.10.8

No Comments

(Required)
(Required, will not be published)
CommentLuv Enabled