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

simon georges’s picture

This 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->mail filled, and simplenews will complete everything.

Anyway, if you can provide anything to help us debug, it would be great.

_snake_’s picture

Thanks,

finally I solved the problem modifying the simplenews module to send the Issue to selected users in the newsletter form

simon georges’s picture

Status: Active » Fixed

It's fixed, then ;)
I'm glad you found a solution.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.