By ap on
I want to send out a newsletter using Simplenews but need to do some PHP processing to create specific content for the User to whom, THE MAIL IS BEING SENT. i.e. each mail will be silightly different.
If I use
global $user;
$user-uid;
I only get the userID of the Cron-Job sendind ing the Mail or My-UserID when I send the Newsletter manulally.
Does anyone have a snippet or suggestion of how I can obtain the UserID of the person to whom the mail is being sent?
Thanks
Andy Potter
Comments
Not Possible in current form
As far as can tell it looks like what I need is not possible.
The current logic of Simplenews is such that the Newsletter is prepared as if it were a node. This includes any PHP/HTML
filters etc. During this phase the ID of users who will recieve the Newletter is unknown.
After the Newsletter-preparation the subscription list is searched to see who should receive the letter. At this point one could insert special recipient-related content but it is to late. Any PHP code which was part of the Node has now been evaluated.
Well. I'll have to do what I want some other way.
Does it call the node each mailing
Haven't looked at simplenews, yet. But planning on it in the near future.
If it calls the node during each emailing, you might be able to add a query to the .tpl
Something like:
I'll actually look at it later this week.
I don't think so, but I'm not entirely sure
AFAIK this routine builds the node
these two while loops do the sending.
The outer loop is only concerned about building the Node(email). Not until the query for the inner loop is performed is any information about the user available. The only additional call is to theme. I'm not quite sure if this is what you mean. I'm still a little weak on understanding the flow of the Drupal architecture. But nonetrheless, to me it looks like all node preparation is done in the routine simplenews_node_prepare
Let me know if you find anything after you have a look at thre code.
I've kind of given up on this approach for my current project. I need to get finished rather quickly and It will take me less time to write something from scratch for what I want to do.
Thanks
Andy