Adding a checkbox to a form to allow users to subscribe to newsletter (acymailing)

antonitus

Member
Can someone please tell me if there is a way to add a checkbox, that when selected (ticked), will automatically subscribe a user to an acymailing newsletter list.

For example:
I have a registration form with the main fields such as 'name' and 'email' (which acymailing use to subscribe a user), plus other fields used in my registration form. At the end of the form, I want to add a checkbox saying "Tick here to subscribe to our newsletter". When submitting the form, it should subscribe to the newsletter as well as doing the usual registering of the user (which already works). If unticked, of course, no subscription to the newsletter and the user gets registered the normal way.

What code can I add to this, if it exists?

I know there is a URL hack from acymailing forums, which is this and it works well for me:

/index.php?option=com_acymailing&ctrl=sub&task=optin&hiddenlists=1,4&user[name]={Full_Name}&user={Email_Address}

You can add this to the jump URL section of the form, however, I don't want to do this as I have no real control and the user will automatically be subscribed without their consent. I'm sure there is a data protection act against this and I wouldn't like it if someone did this to me without my consent.

Thanks,
Tony

Fabrik V3.3.2 - Joomla 3.4.1
 
You can add a "Condition" to the redirect plugin to test if the checkbox is checked.

Or you can add a php plugin which is doing this test and then adding the user to acymailing (I don't know exactly if there is an API or if you have to fill the DB directly).
 
Sounds good, although is there a way for the form to do this in the background and then re-directed to a page of my choice, as I have it now, without it going to a page with acymailing information. The above acymailing URL link goes to that page with the acymailing information, which I don't want.

Also, I'm not a PHP guru, so what condition could I use?

Thanks
 
Depending which version of ACY you have, it should have some helper functions which you can use from a form plugin.

Check in ./administrator/components/com_acymailing/helpers and see if there is a helper.php with a function called acymailing_get(), probably somewhere around line 470.

If so then yes, you could write a PHP form submission plugin to use their API, then redirect to your page of choice.

-- hugh
 
Hi Hugh,

Thanks for your response. I can't see this function anywhere in helper.php and even if I did, I wouldn't know how to integrate it. I have the free starter version, so maybe I need to upgrade. I'm just looking for some php code to tell the form that if a checkbox is ticked, then subscribe to acymailing, if not, do nothing with that code and register the user as normal. I can see from the acy forums that there is an option to add a checkbox to the Joomla registration form to allow for this, however I would need to purchase their Enterprise version, which I may do if it works for Fabrik, so maybe there is a way to add it to the Fabrik forms if this exists somewhere?

As acymailing is, in my opinion better and more user friendly than mailchimp, it might be a good idea to create a plugin for acymailing to achieve this in the future. Just a suggestion as I see many people may benefit from this plugin.
 
I just installed the freebie, and it has that function, at line 569.

I'm just looking for some php code to tell the form that if a checkbox is ticked, then subscribe to acymailing,

Yup, and I'm just trying to help. Maybe if you update to the latest version, you'll have the API code we need to do this.

it might be a good idea to create a plugin for acymailing to achieve this in the future

Yup, and helping you achieve what you need would be the first step towards that. I already have the code to do all this, just not in Fabrik, it's in another app of ours.

So, try updating ACY and let me know.

-- hugh
 
I have the Enterprise edition now. I'll take a look at that api and see what I can figure out. I thought I was nearly there yesterday with some code I got from the acy forums, but it didn't really work, even though it looked promising. They were mentioning Chronoforms and how this code worked for them. I couldn't get it to work because of the name and id tags inside the input tag, i.e. <input ... name="xx" id="xx"...>. I couldn't find a way to rename these fields because they are being used already by Fabrik for the fields to work, I presume, so this code would not have worked for me with my current knowledge of coding in Fabrik, which is zero.

What other apps do you have as I'm always interested to purchase that you guys do, especially as you designed such a powerful app like Fabrik that is blowing my mind. I used Fabrik for a short while, just messing about with it, a few years ago and it blew my mind then, but now it is much more powerful with many more powerful plugins. Great Joomla component.

Thanks
Tony
 
You don't need to Enterprise version to get the API, but as long as you have a use for it ...

The code for ACY I have is in the all new Fabble framework (loosely speaking, Fabrik v4), which is what we built the new JED with. They use ACY for all their emails, so we had to provide the functionality for subscribing and unsubscribing users. Anyway, not an app you can purchase. We are working towards releasing Fabrik v4 "some time this year, maybe", but there's a way to go yet. It's a complete rewrite.

I won't be able to do much till next week, as it's already late on Friday, and for once I have a Real Life scheduled for this weekend. But if you bump this thread next week, I'll look at getting something going. Initially probably just some custom code in a generic PHP plugin, although I may get a wild hair and whip up an actual ACY Subscribe plugin.

-- hugh
 
Hugh, you're a star and a genius. I'm not expecting you to write code for it, I just wanted pointing in the right direction, although if you do that plugin, this will benefit thousands of Fabrik users, especially those who have been using acymailing for several years. You'll get more subscribers. Fabrik just gets better and better.
 
Hi Hugh, at your request, a friendly bump to see if you were successful in writing something for this feature. If not, no worries.
 
Not yet, I took the weekend off, then got sick on Monday. Busy playing catch up. And this week looks like being a bear, so ... :/

-- hugh
 
No problem. Hope you're well now. I'm trying to figure this one out myself, but I don't know how to override the 'name' and 'id' in the input tag without disrupting it's functionality as these names are needed in Fabrik for the inputs to work.

I managed to pull this data from the source code of a Joomla registration page that is using the acy subscribe checkbox.
Code:
<input type="checkbox" id="acy_list_2" class="acymailing_checkbox" name="acysub[]" checked="checked" value="2"/>

Not sure if this helps.
 
Hi Hugh,

Just sending a friendly bump again as said you might have figured this one out. It would be a nice plugin to have for all your users.

Regards,
Tony
 
I know this is quite an old thread, but now I am back with another project and I was just wondering whether an acymailing plugin has been created to allow us to check a checkbox or a radio button to subscribe a user to acymailing on a Fabrik form. I searched the plugins but could not find anything. I think it is very important to have this feature. RSForms have this feature so it would be wise to do it with Fabrik as I prefer working with Fabrik compared to RSForms. Fabril is much more powerful.
 
Can I use this code on redirect you posted on another thread to allow a user on the form to click on a 'Yes' and 'No' radio button before sending form for acymailing subscription:

PHP:
$myEmail = '{yourtable___youremail}';
$myName = '{yourtable___yourname}';

if (!empty($myEmail)) {
   if (! include_once JPATH_ADMINISTRATOR . '/components/com_acymailing/helpers/helper.php')
   {
      throw new RuntimeException("Acymailing not installed");
      return false;
    }

//I added this code myself, but it didn't work of course
if(empty($postData['yourtable___newsletter'])) return;   

   $myUser = new stdClass();
   $myUser->email = $myEmail;
   $myUser->name = $myName;

   //If you require a confirmation but don't want the user to have to confirm his subscription via the API, you can set the confirmed field to 1:
   //$myUser->confirmed = 1;
   $subscriberClass = acymailing_get('class.subscriber');
   $subid = $subscriberClass->save($myUser);

   $newSubscription = array();
   $newList = array();
   $newList['status'] = 1;
   $newSubscription[2] = $newList; // Replace 2 with the ID of the list.

   $subscriberClass->saveSubscription($subid,$newSubscription);
}

Thanks
 
Can you point me at the other thread? It should still work, although I haven't tried it for a looong time.

-- hugh
 
In the code you posted, are you really using "{yourtable___youremail}" and "{yourtable___yourname}" in those first two lines?

And I don't know where you are getting $postData from. Just use a placeholder.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top