The following warnings occurred: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.31 (Linux)
|
Adding a subscriber to external newsletter list - Printable Version +- Form Tools (https://forums.formtools.org) +-- Forum: Form Tools (https://forums.formtools.org/forumdisplay.php?fid=1) +--- Forum: General Discussion (https://forums.formtools.org/forumdisplay.php?fid=5) +--- Thread: Adding a subscriber to external newsletter list (/showthread.php?tid=1859) |
Adding a subscriber to external newsletter list - makey - Jan 16th, 2012 Hi, first just want to say i am really enjoying using form tools. I was wondering if anyone has had success adding a checkbox to a form that will add a subscriber to an external newsletter list ( Campaign Monitor in this case ) A test worked using the Campaign Monitor API and adding this code to process.php $result = $cm->subscriberAdd('joe@notarealdomain.com', 'Joe Smith'); But i am unsure where this code should go and how to get the values for email and name from my form. Also, I would need to check if the "subscribe" checkbox is checked. Obviously, I am just starting to learn PHP, but was wondering if anyone could point me in the right direction! Thanks RE: Adding a subscriber to external newsletter list - michatmaster7 - Jan 17th, 2012 Unfortunately, I am waiting on a solution for this, as well. For now, I have my original form set to send me a separate email with the user's name and address if the checkbox is selected. Then I have to manually add them. I've some ideas about making this work in my sleep, but like you, don't know the PHP well enough to give it a go. RE: Adding a subscriber to external newsletter list - makey - Jan 19th, 2012 I seem to have found a way to get this working with Campaign Monitor, I hope it's not too much of a hack since i am just learning. the key was this thread http://forums.formtools.org/showthread.php?tid=1442 which describes the Submission Pre-Parser module: http://modules.formtools.org/submission_pre_parser/ the Submission Pre-Parser module lets you add a rule and some php code that is executed when the form is submitted. mine got a little complicated because we have multiple language sites sharing the same templates but going to different subscriber lists so i had to add hidden values to the forms, but the basic php that i added to the Submission Pre-Parser module was this: require_once('CMBase.php'); $api_key = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; $client_id = null; $campaign_id = null; $list_id = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; $cm = new CampaignMonitor( $api_key, $client_id, $campaign_id, $list_id ); $FirstName = $_POST["FirstName"]; $LastName = $_POST["LastName"]; $name = $FirstName . " " . $LastName; $email = $_POST["Email"]; if ($_POST["Subscribe"] == "1" ) { $result = $cm->subscriberAdd($email, $name); } the top part is straight from the campaign monitor api so that might not apply if you a different email service, then i got the values from my form, then check if the "Subscribe"checkbox is checked, then send to cm Don't know if this helps or not. RE: Adding a subscriber to external newsletter list - Ben - Jan 22nd, 2012 Nice!! Thanks for posting your solution. Hopefully this'll come in handy for other folks. - Ben |