Page 2 of 2
Re: FormBuilder: Add email to mail list in NMS?
Posted: Sun Oct 28, 2012 4:11 pm
by Jos
andrewvideo wrote:Code: Select all
//Add user to NMS
$nms->AddUser($email, $list, $name);
echo $nms->AddUser($email, $list, $name);
Seems to me you're adding the new user twice?
To answer your question, why not use:
Code: Select all
$adduser = $nms->AddUser($email, $list, $name, $disabled, $confirmed);
of course you have to set the variables $disabled and $confirmed before that line to 0 and 1.
Re: FormBuilder: Add email to mail list in NMS?
Posted: Sun Oct 28, 2012 11:23 pm
by andrewvideo
This should work now.
Code: Select all
$gCms = cmsms();
$nms = cms_utils::get_module('NMS');
if(!is_object($nms))
return false;
if (!isset($params['name']) && !isset($params['email']) && !isset($params['list']))
return;
$name = '';
if (isset($params['name']))
$name = $params['name'];
$email = '';
if (isset($params['email']))
$email = $params['email'];
$list = '';
if (isset($params['list']))
$list = 1;
//This is a mandatory list ID all should belong to
//Add user to NMS
//array(1) -- represents the id of the mailing list to add them to. Change the 1 to whatever you want.
$nms->AddUser($email, array(1), $name);
//Set the confirmed flag to true (they clicked the checkbox -- that's enough)
$db =& $gCms->GetDb();
$db->Execute('UPDATE ' . cms_db_prefix() . 'module_nms_users SET confirmed = 1 where email = ?', array($email));
Re: FormBuilder: Add email to mail list in NMS?
Posted: Mon Oct 29, 2012 12:49 am
by andrewvideo
Jos wrote:andrewvideo wrote:Code: Select all
//Add user to NMS
$nms->AddUser($email, $list, $name);
echo $nms->AddUser($email, $list, $name);
Seems to me you're adding the new user twice?
To answer your question, why not use:
Code: Select all
$adduser = $nms->AddUser($email, $list, $name, $disabled, $confirmed);
of course you have to set the variables $disabled and $confirmed before that line to 0 and 1.
The code is working great, it checks if the user is on list or not. if not add them, fine thats working great. I want to check if aswell if they on the list and have confirmed or not. Whats happiing is if the user already on the list it unconfirmeds them, What do I need to add? How i check first DB?