Closed (fixed)
Project:
Simplenews
Version:
6.x-1.1
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
4 Nov 2010 at 16:47 UTC
Updated:
29 Nov 2010 at 10:10 UTC
Hi,
I have a field in newsletter form to send that to another email users. I have a Rules Trigger to send the newsletter when the content is saved. But it doesn't work. I need help..is there another way to do that?
That's the Rules code
/**
* Send newsletter node to subcribers.
*
* @param integer or object $node Newsletter node to be sent. integer = nid; object = node object
* @param array $accounts account objects to send the newsletter to.
* account = object (
* snid = subscription id. 0 if no subscription record exists
* tids = array(tid) array of newsletter tid's
* uid = user id. 0 if subscriber is anonymous user.
* mail = user email address.
* name = <empty>. Added for compatebility with user account object
* language = language object. User preferred of default language
* )
* NOTE: either snid, mail or uid is required.
*/
class Cuenta
{
var $snid;
var $tids;
var $uid;
var $mail;
var $name;
var $language;
}
$accounts = array();
$cuentas = array();
$account = new Cuenta();
foreach ($node->field_envio_otros_destinatarios as $destinatario)
{
$account->snid = 0;
$account->tids = array();
$account->uid = 0;
$account->mail = $destinatario->value;
$account->name = '';
$account->language = "es";
array_push($accounts,$account);
array_push($cuentas,$destinatario);
}
simplenews_send_node($node, $accounts);
Comments
Comment #1
simon georges commentedThis should apparently do the trick. Do you have some kind of error message ? Something in the watchdog to help us analyse the situation ?
Actually, I think you could simplify your code : as simplenews with systematically rebuild the account object (because it will not find any subscription in the database), you can create an object with only
$account->mailfilled, and simplenews will complete everything.Anyway, if you can provide anything to help us debug, it would be great.
Comment #2
_snake_ commentedThanks,
finally I solved the problem modifying the simplenews module to send the Issue to selected users in the newsletter form
Comment #3
simon georges commentedIt's fixed, then ;)
I'm glad you found a solution.