FormBuilder: Add email to mail list in NMS?

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Jos
Support Guru
Support Guru
Posts: 4017
Joined: Wed Sep 05, 2007 8:03 pm
Location: The Netherlands

Re: FormBuilder: Add email to mail list in NMS?

Post 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.
andrewvideo
Forum Members
Forum Members
Posts: 127
Joined: Fri Nov 28, 2008 10:28 pm

Re: FormBuilder: Add email to mail list in NMS?

Post 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));

andrewvideo
Forum Members
Forum Members
Posts: 127
Joined: Fri Nov 28, 2008 10:28 pm

Re: FormBuilder: Add email to mail list in NMS?

Post 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?
Locked

Return to “Modules/Add-Ons”