×

info

Dear guests,
You are currently on the old forum we kept as a knowledge base. You will find the new community forum here
Welcome, Guest
Username: Password: Remember me
Keyword

TOPIC: Auto subscribe to one list and to another list just if checkbox is flag

Auto subscribe to one list and to another list just if checkbox is flag 3 years 8 months ago #105832

  • Anonymous user
  • panta7's Avatar
  • Posts: 55
  • Karma: 0
Hello,
I have a RSform pro contact form, I would like to auto subscribe a user to one list and subscribe him to another list just if a checkbox is flag.
I read your documentation and found a solution for autosubscribe and a solution for subscribe with the check box but I don't know how to use both together. Can someone help me, please? Thanks.
Please log in to post a reply

Auto subscribe to one list and to another list just if checkbox is flag 3 years 8 months ago #105845

  • Alexandre
  • Alexandre's Avatar
  • Posts: 2462
  • Karma: 67
Hi,

Feel free to take a look at our developer documentation :
www.acyba.com/acymailing/64-acymailing-d....html#api_insertuser
You will find all the needed information you need :)
Last Edit: 3 years 8 months ago by Alexandre.
Please log in to post a reply

Auto subscribe to one list and to another list just if checkbox is flag 3 years 8 months ago #105855

  • Anonymous user
  • panta7's Avatar
  • Posts: 55
  • Karma: 0
Thanks for the link, anyway I'm not a developer and need more help, please.
This is the code I use to subscribe an user to newsletter ID:1 only if he flag the checkbox and it works fine but I would like to automatically add him to another newsletter (ID:2) even if he doesn't flag the checkbox. Can you help me to edit my code, please? Thanks.
$postData = JRequest::getVar('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']); //Please replace email_field by your own field name (the name of the field "email").
 $myUser->name = strip_tags($postData['Nome']); //Please replace name_field by your own field name (the name of the field "name").
 $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);
Please log in to post a reply

Auto subscribe to one list and to another list just if checkbox is flag 3 years 8 months ago #105864

  • Alexandre
  • Alexandre's Avatar
  • Posts: 2462
  • Karma: 67
Hi,

This should do the job :
$myUser = new stdClass();
 $myUser->email = strip_tags($postData['Email']); //Please replace email_field by your own field name (the name of the field "email").
 $myUser->name = strip_tags($postData['Nome']); //Please replace name_field by your own field name (the name of the field "name").
 $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.
 
//If the subscribeme option is checked we subscribe him to 1 else we subscribe him to 2.
if(!empty($postData['subscribeme'])) $subscribe = array(1); 
else $subscribe = array(2); 

$newSubscription = array();
 if(!empty($subscribe)){
 foreach($subscribe as $listId){
 $newList = array();
 $newList['status'] = 1;
 $newSubscription[$listId] = $newList;
 }
 }
 $subscriberClass->saveSubscription($subid,$newSubscription);
Please log in to post a reply

Auto subscribe to one list and to another list just if checkbox is flag 3 years 8 months ago #105868

  • Anonymous user
  • panta7's Avatar
  • Posts: 55
  • Karma: 0
Sorry, you code doesn't works.
The correct code is this:
$postData = JRequest::getVar('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']); //Please replace email_field by your own field name (the name of the field "email").
 $myUser->name = strip_tags($postData['Nome']); //Please replace name_field by your own field name (the name of the field "name").
 $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.
 
//If the subscribeme option is checked we subscribe him to 1 else we subscribe him to 2.
if(!empty($postData['subscribeme'])) $subscribe = array(1,2); 
else $subscribe = array(2); 

$newSubscription = array();
 if(!empty($subscribe)){
 foreach($subscribe as $listId){
 $newList = array();
 $newList['status'] = 1;
 $newSubscription[$listId] = $newList;
 }
 }
 $subscriberClass->saveSubscription($subid,$newSubscription);
Please log in to post a reply
Time to create page: 0.066 seconds
Powered by Kunena Forum