Personlized Newsletter (second)

drizzi - April 24, 2009 - 13:22
Project:Simplenews
Version:6.x-1.x-dev
Component:Usability
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active
Description

hello all,

reading through the issues posted here confused me. i am looking for a possibility to collect more user data while subscribing the first time for newsletters; storing these data in the database and use them for personlized newsletters.

is there a clear description how to patch the recent version ?
are any extending modules under development or even available ?

thanks for support in advance
steffen

#1

eax - April 24, 2009 - 14:16

Hi there,

I just came across a possibility to use any user-relevant data inside a personlized newsletter. My situation was as follows:

I needed a newsletter that changed its contents based on the interests of the user. The admin would have to create just one newsletter and assign the relevant topics to the different content snippets. After doing lots of research and puzzling myself, I finally found a solution. I made a tiny modification to simplenews_mail_mail():

function simplenews_mail_mail($nid, $vid, $mail, $key = 'node') {
  // Get subscription data for recipient and language
  global $simplenews_account; // This line
 
  $account = new stdClass();
  $account->mail = $mail;
  $subscription = simplenews_get_subscription($account);
 
  $simplenews_account=$subscription; // And this one also.

Now I'm able to use $simplenews_account in my simplenews-newsletter-body.tpl.php. By making a manual database query I fetch the user and profile data from the email carried in $simplenews_account->mail. The code looks like this:

global $simplenews_account;

$result = db_query("SELECT uid FROM {users} WHERE mail = '%s' LIMIT 1", $simplenews_account->mail);
$field = db_fetch_object($result);

$recipient = user_load(array('uid'=>$field->uid));
profile_load_profile($recipient);

From this point on I'm able to use the complete user profile in $recipient.

But... there's an incredible important problem with this solution: Because of the template caching only one single email could be sent during a cron run. I set mine to run every single minute, and it's okay for my needs. So, if you have loads of subscribers, prepare to wait serveral ages for transport the newsletter to all recipients ;)

#2

drizzi - April 24, 2009 - 14:45

hi eax,

thanks for the reply - but i am not sure if this would a solution for us. i would prefer a solution like integration some of the functionlities of phplist in simplenews.

just a small form asking for surname and lastname, emailadress and maybe some more fields, storing them in the database and make them available for the newsletter templates.

what i am not looking for - enforcing the receipants to do a full registration in drupal.

thanks again
steffen

#3

eax - April 24, 2009 - 15:09

What I do is disguising the full registration as a subscription to the newsletter. I'm not sure if it'll be a good idea just to store some values in the database. Remember that you need to give the subsciptors a possibility to unsubscribe or alter personal informations, such as name or email-adress.

I think the drupal user role system is flexible enough to restrict user accounts to this functionality only.

Just a quick thought, maybe someone else likes to comment on that as well.

#4

drizzi - May 28, 2009 - 19:55

i even do not like a full registration to drupal - but i follow the lights of cordiality. a newsletter starting with

"dear mr. miller" is more polite than "to all receivers"... :-)

greetings
steffen

#5

drizzi - October 4, 2009 - 09:58

hello all,

still nothing new about personalized newsletters?

steffen

 
 

Drupal is a registered trademark of Dries Buytaert.