https://docs.acymailing.com/v/old/developers/subscription-via-url/rsform-pro-and-acymailing

If you use RSForm!Pro on your website, you can integrate AcyMailing with RSForm!Pro so that when a user submits a form, this user is also subscribed to one or several AcyMailing Lists.
There are three ways to do this. The recommended method is to use php code to add the user after the form is submitted.

 

Integration with RSForm!Pro

Integrate AcyMailing and RSForm!Pro using php code
You can configure RSForm!Pro to execute this php code to subscribe the user to AcyMailing.
This script should go in the Script called after form has been processed area in RSForm!Pro. You can find this area when editing your form, in the property tab, PHP Scripts part.
Don't forget to replace in the following code the name of the email and name fields by the ones of your form as well as putting the list ID you want to subscribe the users to. See comments in the code below.
 
 
$postData = $_REQUEST['form'];
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($postData['email_field']); //Please replace email_field by your own field name (the name of the field "email"). 
$myUser->name = strip_tags($postData['name_field']); //Please replace name_field by your own field name (the name of the field "name"). 
$subscriberClass = acymailing_get('class.subscriber'); 
$subscribe = array(3,4,5); //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.
$_REQUEST['subscription'] = $subscribe; //Only useful when using a subscription condition in the "Create Joomla user" plugin, you can delete this line if you don't use this plugin 
$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. 
$newSubscription = array(); 
if(!empty($subscribe)){ 
foreach($subscribe as $listId){ 
$newList = array(); 
$newList['status'] = 1; 
$newSubscription[$listId] = $newList; 
} 
} 
$subscriberClass->saveSubscription($subid,$newSubscription);
 
 
You may want to subscribe the user to AcyMailing only if he checks a box to really opt in... If it's the case, you should call your checkbox "subscribeme" and use this php code:
 
$postData = $_REQUEST['form'];
if(empty($postData['subscribeme'])) return;
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($postData['email_field']); //Please replace email_field by your own field name (the name of the field "email"). 
$myUser->name = strip_tags($postData['name_field']); //Please replace name_field by your own field name (the name of the field "name"). 
$subscriberClass = acymailing_get('class.subscriber'); 
$subscribe = array(3,4,5); //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.
$_REQUEST['subscription'] = $subscribe; //Only useful when using a subscription condition in the "Create Joomla user" plugin, you can delete this line if you don't use this plugin 
$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. 
$newSubscription = array(); 
if(!empty($subscribe)){ 
foreach($subscribe as $listId){ 
$newList = array(); 
$newList['status'] = 1; 
$newSubscription[$listId] = $newList; 
} 
} 
$subscriberClass->saveSubscription($subid,$newSubscription);
 
 
Visitez le lien pour d'autres méthodes d'intégration