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.
RazorMedia

FormBuilder: Add email to mail list in NMS?

Post 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?
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

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

Post 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.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
sn3p
Forum Members
Forum Members
Posts: 169
Joined: Mon Oct 15, 2007 2:27 pm

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

Post 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).
Last edited by sn3p on Thu Aug 27, 2009 3:48 pm, edited 1 time in total.
User avatar
chuckienorton
Forum Members
Forum Members
Posts: 68
Joined: Wed Feb 14, 2007 6:58 pm
Location: Pasadena, California

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

Post 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.
Sjoz

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

Post 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
chrismarie

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

Post 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
Last edited by chrismarie on Mon Feb 09, 2009 9:17 pm, edited 1 time in total.
TxinO

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

Post 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!
Last edited by TxinO on Sat Feb 21, 2009 6:59 pm, edited 1 time in total.
giggler
Forum Members
Forum Members
Posts: 197
Joined: Tue Oct 09, 2007 7:08 am

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

Post 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"
Last edited by giggler on Thu May 21, 2009 7:25 am, edited 1 time in total.
pedes
Power Poster
Power Poster
Posts: 840
Joined: Tue Jan 27, 2009 11:47 am

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

Post 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
maranc
Forum Members
Forum Members
Posts: 249
Joined: Tue May 04, 2010 5:04 pm

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

Post by maranc »

http://forum.cmsmadesimple.org/index.ph ... 004.0.html

Check this topic ...

Best regards,
Marek A.
pedes
Power Poster
Power Poster
Posts: 840
Joined: Tue Jan 27, 2009 11:47 am

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

Post 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
Last edited by pedes on Wed May 26, 2010 5:12 pm, edited 1 time in total.
webform
Power Poster
Power Poster
Posts: 458
Joined: Sat Nov 25, 2006 3:39 pm
Location: Copenhagen, Denmark

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

Post 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!
konsument
Forum Members
Forum Members
Posts: 137
Joined: Thu Oct 26, 2006 9:20 am
Location: Dresden - Saxony - Germany

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

Post by konsument »

problem solved.. :)
beherenow_uk
Forum Members
Forum Members
Posts: 103
Joined: Fri Nov 28, 2008 11:26 am

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

Post 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.
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 »

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
Locked

Return to “Modules/Add-Ons”