Page 1 of 2

FormBuilder: Add email to mail list in NMS?

Posted: Wed May 30, 2007 7:43 am
by RazorMedia
Is there a way in FormBuilder to add, for instance, a checkbox to add users email to mail list in NMS?

I saw that there was an field type option: "Call A User Defined Tag With the Form Results". Waybe there´s a way to add this functionailty with a User Defined Tag.

Any suggestions on how to proceed?

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

Posted: Wed May 30, 2007 2:02 pm
by calguy1000
No, there is no built in integration between formbuilder and NMS.

However, you are correct, you should be able to write a UDT to subscribe/unsubscribe a person to a particular NMS list based on a checkbox in a formbuilder form.

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

Posted: Thu Sep 25, 2008 3:46 pm
by sn3p
I made an UDT for this:

Code: Select all

if (!isset($params['Subscribe']) && !isset($params['E-mail']))
	return;

$subscribe = $params['Subscribe'];
if ($subscribe != 'Yes')
	return;

$name = '';
if (isset($params['Name']))
	$name = $params['Name'];

global $gCms;
if (!isset($gCms->modules['NMS']))
	return;

$nms = $gCms->modules['NMS']['object'];
$mid = 'm' . ++$gCms->variables["modulenum"];

$params['email'] = $params['E-mail'];
$params['username'] = $name;
// array with list id's
$params['lists'] = array(1);
// return id used for link in confirmation mail
$returnid = 65;

$nms->DoAction('do_create_new_user',$mid,$params,$returnid);
Subscribe is the name of the subscribe checkbox in FormBuilder, where values can be 'Yes' (checked) or 'No' (unchecked).

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

Posted: Sat Oct 25, 2008 7:26 pm
by chuckienorton
SN3P,  Thanks for how-to. But I'm confused... where does this code go? Do you mind giving just a little more detail for lesser mortals like myself?  ???

Thanks man.

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

Posted: Tue Jan 27, 2009 11:08 pm
by Sjoz
We (Eus and me) solved your problem.

- Create a UDT name it "subscription".
- Place the code above in it.
- Create in Formbuilder in your form a field of the type "*Call A User Defined Tag With the  Form Results"
- Also create a checkbox as mentioned above in the formbuilder.

Grtz,
2nFuse

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

Posted: Mon Feb 09, 2009 8:21 pm
by chrismarie
Thanks for the help with the UDT.  I followed your instructions and pasted the code into a UDT named subscription, but after I hit submit, the form bounces from http://www.coachterri.com/archive to a 404 page not found:
http://www.coachterri.com/archive/index ... &m3error=1

The email isn't getting stored in the NMS database, but the send to email function that I have on the form still works.  How can I modify the UDT to fix this?  I just want the form to load the formbuilder submission template.  I'm trying to figure this out on my own, but it's not going so well with my limited knowledge of php.

Also, is it possible to have the user subscribe without the addition of the checkbox?  All I want the form to say is : Name ______ Email _______ Submit [] and when the submit button is clicked, the username and email are submitted to NMS.

Is this possible with the UDT, or is the checkbox an absolute necessity.  It's not a huge deal if it's too difficult. Thanks so much!

Install Info:
CMSMS      v.1.5.2
Blogs        0.3.3.1
Captcha      0.3.2
CGExtensions  1.15
CMSMailer      1.73.14
CustomContent  1.5.2
FileManager  0.4.3
FormBuilder  0.5.11
FrontEndUsers  1.6.2
MenuManager  1.5.3
ModuleManager  1.2.1
News        2.9.2
NMS        2.2
nuSOAP      1.0.1
Printing      0.2.6
Search      1.5.2
ThemeManager  1.0.8
TinyMCE      2.4.11

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

Posted: Sat Feb 21, 2009 6:40 pm
by TxinO
Hi there,

first of all, this is my first post, I want to thank the whole team and community for the INCREDIBLE JOB... KEEP IT UP!

And now with the topic.

I had your same situation, did include the code on UDT and linked to a form with checkbox as described, when I first tested I had a similar error, got redirected to a URL with all the parameters listed on it, went through the code in the UDT and realized that my "email" field wasn't exactly identified as "E-mail", so I changed the "E-mail" identifier to match the name of my email field and it worked just perfect.

I mean that's what the code is doing, first is checking that the value of that field (email) isn't empty and then is using the value (stored in the variable to send to NMS) to send it to the newsletter list, so in order to do this it has to find the value of the specified field, and so if the field of the email (the user's email) can't be find (as the name of the field in the code is different from the name of the field in your form) then it's not possible to store the email on the NMS list thus we get the error.

Don't know if I've explained my self properly, in other words, change $params['E-mail'] (that you'll find twice in the provided code) to match the exact name of your email field.

And for the second part of your question, you can do that (form with Name and Email to NMS) exactly with this smarty:

{cms_module module='NMS' mode="subscribe" select="NAME OF YOUR NEWSLETTER LIST"}

With this you will get a form with 2 fields, one for the email and the other one for the Name, with a checkbox (marked and uneditable) and as label of that checkbox you get the name of your list and the description, haven't got to deep into that, but if you go into the NMS module and the Subscription tab, you will be able to edit that form, and with a bit of CSS you have it all done.

Well hope it all helps, and you can accomplish what you started.

I forgot THANKS FOR THE UDT AND THE WHOLE THREAD!! It helped me alot!

All the best!

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

Posted: Thu May 21, 2009 7:16 am
by giggler
This worked great. Had a question:

When a user is created using this method the user had "confirmed - no" - is there a way to have the UDT send an email to the user for confirmation email OR have it automatically marked as "confirmed - yes"?

UPDATE: Actually it did send an confirmation email - but when I click on the email it goes to a "page not found"

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

Posted: Wed May 26, 2010 4:07 pm
by pedes
has someone got this working ?
Sjoz wrote: We (Eus and me) solved your problem.

- Create a UDT name it "subscription".
- Place the code above in it.
- Create in Formbuilder in your form a field of the type "*Call A User Defined Tag With the  Form Results"
- Also create a checkbox as mentioned above in the formbuilder.

Grtz,
2nFuse

I did this and the email is not added to my NMS list, i get no error's

kind regards
Peter

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

Posted: Wed May 26, 2010 4:26 pm
by maranc
http://forum.cmsmadesimple.org/index.ph ... 004.0.html

Check this topic ...

Best regards,
Marek A.

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

Posted: Wed May 26, 2010 4:31 pm
by pedes
pedes wrote: has someone got this working ?
Sjoz wrote: We (Eus and me) solved your problem.

- Create a UDT name it "subscription".
- Place the code above in it.
- Create in Formbuilder in your form a field of the type "*Call A User Defined Tag With the  Form Results"
- Also create a checkbox as mentioned above in the formbuilder.

Grtz,
2nFuse

I did this and the email is not added to my NMS list, i get no error's

kind regards
Peter
maybe i did something wrong ???

- made the UDT with the code above and named it "subscription"
- put a email field in the form, named it "E-mail"
- i also have a field for a username, named it "Name"
- i made a checkbox, named it "Subscribe" and let it standard 'checked'
- i made a field of the type "*Call A User Defined Tag With the  Form Results", named it udt

is there something else to do ? my NMS list is created, i named it 'newsletter'

any idea ?

Kind regards,
Peter

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

Posted: Thu Jun 03, 2010 2:20 pm
by webform
I've discovered you need to give the 3 fields an alias in FormBuilder and then use these params names in your UDT before it works.

I've have also made an alternative UDT, based on Ted's UDT "FrontEndUsers to NMS (via SelfRegistration)" (http://forum.cmsmadesimple.org/index.php/topic,34004.0.html), setting the user to "Confirmed" without sending an email.

Code: Select all

if (!function_exists('MyGetModuleInstance'))
{
        function &MyGetModuleInstance($module)
        {
                global $gCms;

                if (isset($gCms->modules[$module]) &&
                        $gCms->modules[$module]['installed'] == true &&
                        $gCms->modules[$module]['active'] == true)
                {
                        return $gCms->modules[$module]['object'];
                }
                // Fix only variable references should be returned by reference
                $tmp = FALSE;
                return $tmp;
        }
}

global $gCms;

$nms = MyGetModuleInstance('NMS');

if ($nms == FALSE)
  return false;

if (!isset($params['subscribe']) && !isset($params['email']))
	return;

$subscribe = $params['subscribe'];
if ($subscribe != 'Yes')
	return;

$name = '';
if (isset($params['name']))
	$name = $params['name'];
	
$email = '';
if (isset($params['email']))
	$email = $params['email'];


        //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));
The params names are the field alias in FormBuilder!

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

Posted: Tue Jul 26, 2011 1:27 pm
by konsument
problem solved.. :)

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

Posted: Sun Jul 08, 2012 2:12 pm
by beherenow_uk
Hi all,

Can't get this to work in the latest CMSMS 1.10.3 / NMS 2.4.3 / formbuilder 0.7.2

Any ideas? Perhaps something has changed in the latest core to prevent it from working anymore?

I've followed all of the above instructions and carefully and tried the alternative UDT shared by webform, but still no joy.

Cheers.

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

Posted: Sun Oct 28, 2012 1:03 pm
by andrewvideo

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']))
   $newslist = 1;


$list = 1;




//This is a mandatory list ID all should belong to



       //Add user to NMS
$nms->AddUser($email, $list, $name);

echo $nms->AddUser($email, $list, $name);
       //Set the confirmed flag to true
       $db = cmsms()->getDB;

       $db->Execute('UPDATE ' . cms_db_prefix() . 'module_nms_users SET confirmed = 1 where email = ?', array($email));
I update the code but last bottom lines are not working,. Can someone help us to get this to work,

Cheers