× Form Help

breezing and acymailing in different lists by language

  • Webmarketingtrento
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 15
  • Thank you received: 0

Webmarketingtrento created the topic: breezing and acymailing in different lists by language

Hi I have a form that sends to the language based address to different pages of "thank you", code below:

$this->execPieceByName('ff_InitLib');
$lang = JFactory::getLanguage();
$i = $lang->getTag();
switch ($i)
{
case "it-IT" :
ff_redirect('/it/grazie');
break;
case "en-GB":
ff_redirect('/en/thank-you');
break;
case "de-DE":
ff_redirect('/de/danke');
break;
case "sv-SE" :
ff_redirect('/sv/tack-vare');
break;
}

I would like the user who requested information to check the "I want to subscribe to the newsletter" field to be saved in the language specific acymailing list. I have 4 languages and 4 different acymailing lists.

Can you help me thanks?
#236383
  • Posts: 2461
  • Karma: 86
  • Thank you received: 333

mihaela replied the topic: breezing and acymailing in different lists by language

Hello,

Please take a look at this topic crosstec.org/en/forums/1-forums/124109-p...funciona.html#226459 where it is successfully integrated with the acymailing list.

In your case you would add a condition like this:
if($i =="it-IT" ) {
 $subscribe = array(1); //Specify here the ID of your lists separated by a comma, in this example the user will be subscribed to list 1.
 $newSubscription = array();
 if(!empty($subscribe)){
 foreach($subscribe as $listId){
 $newList = array();
 $newList['status'] = 1;
 $newSubscription[$listId] = $newList;
 }
 }
 $subscriberClass->saveSubscription($subid,$newSubscription);
}
else if($i =="en-GB" ) {
 $subscribe = array(2); //Specify here the ID of your lists separated by a comma, in this example the user will be subscribed to list 2.
 $newSubscription = array();
 if(!empty($subscribe)){
 foreach($subscribe as $listId){
 $newList = array();
 $newList['status'] = 1;
 $newSubscription[$listId] = $newList;
 }
 }
 $subscriberClass->saveSubscription($subid,$newSubscription);
}

You can also take a look at this example crosstec.org/en/forums/3-breezingforms-f...g-tables.html#207899 .

Let me know whether it helped you achieve what you want.

Regards,

Mihaela
#236386
  • Webmarketingtrento
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 15
  • Thank you received: 0

Webmarketingtrento replied the topic: breezing and acymailing in different lists by language

Thanks Mihaela, I integrated part of the code before the redirect, like this:

$this->execPieceByName('ff_InitLib');
$lang = JFactory::getLanguage();
$i = $lang->getTag();
switch ($i)
{
case "it-IT" :

$subscribe = array(1); //Specify here the ID of your lists separated by a comma, in this example the user will be subscribed to list 1.
$newSubscription = array();
if(!empty($subscribe)){
foreach($subscribe as $listId){
$newList = array();
$newList = 1;
$newSubscription[$listId] = $newList;
}
}
$subscriberClass->saveSubscription($subid,$newSubscription);

ff_redirect('it/grazie');
break;
case "en-GB":
$subscribe = array(2); //Specify here the ID of your lists separated by a comma, in this example the user will be subscribed to list 2.
$newSubscription = array();
if(!empty($subscribe)){
foreach($subscribe as $listId){
$newList = array();
$newList = 1;
$newSubscription[$listId] = $newList;
}
}
$subscriberClass->saveSubscription($subid,$newSubscription);
ff_redirect('/en/thank-you');
break;
case "de-DE":

$subscribe = array(3); //Specify here the ID of your lists separated by a comma, in this example the user will be subscribed to list 2.
$newSubscription = array();
if(!empty($subscribe)){
foreach($subscribe as $listId){
$newList = array();
$newList = 1;
$newSubscription[$listId] = $newList;
}
}
$subscriberClass->saveSubscription($subid,$newSubscription);

ff_redirect('/de/danke');
break;
case "sv-SE" :

$subscribe = array(4); //Specify here the ID of your lists separated by a comma, in this example the user will be subscribed to list 2.
$newSubscription = array();
if(!empty($subscribe)){
foreach($subscribe as $listId){
$newList = array();
$newList = 1;
$newSubscription[$listId] = $newList;
}
}
$subscriberClass->saveSubscription($subid,$newSubscription);

ff_redirect('/sv/tack-vare');
break;
}

but returns "Call to a member function saveSubscription() on null"

$subscriberClass is null, where and how do I define it?

thanks
#236411
  • Posts: 2461
  • Karma: 86
  • Thank you received: 333

mihaela replied the topic: breezing and acymailing in different lists by language

Hello again,

From what I can see, I see you haven't put there the complete code to integrate with acymailing. In this link crosstec.org/en/forums/1-forums/124109-p...funciona.html#226459 you can see the example of the whole code:
$this->execPieceByName('ff_InitLib');
  include_once(rtrim(JPATH_ADMINISTRATOR,DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'components'.DIRECTORY_SEPARATOR.'com_acymailing'.DIRECTORY_SEPARATOR.'helpers'.DIRECTORY_SEPARATOR.'helper.php');
 
 $myUser = new stdClass();
 $myUser->email = strip_tags(ff_getSubmit('email_solicitante'));
 $myUser->name = strip_tags(ff_getSubmit('nome_solicitante'));

 $subscriberClass = acymailing_get('class.subscriber');
 $subid = $subscriberClass->save($myUser);
 
$subscriberClass->sendConf($subid); //we send the confirmation email... only if needed based on the current user status and the option from the Acy configuration page.

 $subscribe = array(1); //Specify here the ID of your lists separated by a comma, in this example the user will be subscribed to lists IDs 3,4 and 5.
 $newSubscription = array();
 if(!empty($subscribe)){
 foreach($subscribe as $listId){
 $newList = array();
 $newList['status'] = 1;
 $newSubscription[$listId] = $newList;
 }
 }
 $subscriberClass->saveSubscription($subid,$newSubscription);
I've just sent you the code starting from this part
$subscribe = array(1);
since here you change the code depending on the condition.

Let me know whether you've managed to make it work with the whole code.

Regards,

Mihaela
#236413
  • Webmarketingtrento
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 15
  • Thank you received: 0

Webmarketingtrento replied the topic: breezing and acymailing in different lists by language

I have integrated the missing part but it returns error:
"Call to undefined function acymailing_get ()"

----

$this->execPieceByName('ff_InitLib');
include_once(rtrim(JPATH_ADMINISTRATOR,DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'components'.DIRECTORY_SEPARATOR.'com_acymailing'.DIRECTORY_SEPARATOR.'helpers'.DIRECTORY_SEPARATOR.'helper.php');

$myUser = new stdClass();
$myUser->email = strip_tags(ff_getSubmit('email'));
$myUser->name = strip_tags(ff_getSubmit('nome'));

$subscriberClass = acymailing_get('class.subscriber');
$subid = $subscriberClass->save($myUser);

$subscriberClass->sendConf($subid); //we send the confirmation email... only if needed based on the current user status and the option from the Acy configuration page.

$lang = JFactory::getLanguage();
$i = $lang->getTag();
switch ($i)
{
case "it-IT" :
$subscribe = array(1); //Specify here the ID of your lists separated by a comma, in this example the user will be subscribed to list 1.
$newSubscription = array();
if(!empty($subscribe)){
foreach($subscribe as $listId){
$newList = array();
$newList = 1;
$newSubscription[$listId] = $newList;
}
}
$subscriberClass->saveSubscription($subid,$newSubscription);

ff_redirect('/it/grazie');
break;

case "en-GB":
$subscribe = array(2); //Specify here the ID of your lists separated by a comma, in this example the user will be subscribed to list 2.
$newSubscription = array();
if(!empty($subscribe)){
foreach($subscribe as $listId){
$newList = array();
$newList = 1;
$newSubscription[$listId] = $newList;
}
}
$subscriberClass->saveSubscription($subid,$newSubscription);

ff_redirect('/en/thank-you');
break;


case "de-DE":
$subscribe = array(3); //Specify here the ID of your lists separated by a comma, in this example the user will be subscribed to list 2.
$newSubscription = array();
if(!empty($subscribe)){
foreach($subscribe as $listId){
$newList = array();
$newList = 1;
$newSubscription[$listId] = $newList;
}
}
$subscriberClass->saveSubscription($subid,$newSubscription);

ff_redirect('/de/danke');
break;


case "sv-SE" :

$subscribe = array(4); //Specify here the ID of your lists separated by a comma, in this example the user will be subscribed to list 2.
$newSubscription = array();
if(!empty($subscribe)){
foreach($subscribe as $listId){
$newList = array();
$newList = 1;
$newSubscription[$listId] = $newList;
}
}
$subscriberClass->saveSubscription($subid,$newSubscription);
ff_redirect('/sv/tack-vare');
break;
}



----


I don't want the problem to be due to the fact that I use AcyMailing Enterprise 6.1.1
#236432
  • Posts: 2461
  • Karma: 86
  • Thank you received: 333

mihaela replied the topic: breezing and acymailing in different lists by language

Hello,

In that case, please try these two fixes:

1) In these lines of code:
$myUser->email = strip_tags(ff_getSubmit('email'));
$myUser->name = strip_tags(ff_getSubmit('nome'));
I didn't note especailly that "email" and "nome" in ff_getSubmit('email') and ff_getSubmit('nome') have to be the names of elements in your form where person submitting the form fill in their email and name. In case these fields are named differently in your form please change that in the code to:
$myUser->email = strip_tags(ff_getSubmit('YourEmailField'));
$myUser->name = strip_tags(ff_getSubmit('YourNameField'));

Save this change and see whether the error is gone.

2) If 1) doesn't change anything, please also try to remove the redirecting pieces of code:
ff_redirect('/it/grazie');
for each language since it might be that both redirecting like that and ACYMAILING redirecting can't work simultaneously.

Let me know the result.

Regards,

Mihaela
#236474
Moderators: ForumSupporttomeperica
Time to create page: 0.078 seconds

New Icon Packs Category!

Crosstec is now offering icon packs.

If you are a paying subscriber, icon packs are automatically added to your account.

Check out our icon packs page!

Live Support Chat Opened!

Join our Discord chat here to receive live support and talk directly to the team!

Summer Sale!

50% discount on all of our extension subscription plans, templates and icon packs!

Get Your Subscription Here

News and Updates

Get informed about new downloads, updates and more in our News and Updates newsletter.

All Extensions Subscription

Get 1 year access to all of our current and future products and 1 year of professional support -- 99 for just 49! (Summer Sale)

No support per domain or website installation limits! Includes all of our current and future Joomla!® extensions, Joomla!® templates for the duration of your membership. This means, by purchasing an All Extensions Subscription you'll have it all covered!

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!

Live Support Chat Opened!

Join our Discord chat here to receive live support and talk directly to the team!

Community Reward

Help us to create new extensions and plugins! With only $5 you help us a lot and get unlimited download access to all of our products, professional support and even more. Get your reward now!

Read More Here