• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: Connecting ACYMailing and RSFromsPro

Connecting ACYMailing and RSFromsPro 8 years 4 months ago #36138

I wanted to create a new user in ACYMailing based on data entered in fields in an RSFormsPro Petition form: After a lot of back an forth, this is what I came up with.

I just wanted to share this with anyone else interested in creating new ACYMailing User from RSFormsPro data.

The below would be enter in the PHP Scripts area in the "Script called after form has been processed" area. While this is specific to what I needed to accomplish, I am confident that it can be adapted to anyone's ACYMailing subscription form.
$postData = JRequest::getVar('form');
if(empty($postData['my_form_subscribe'])) return;
 
include_once(rtrim(JPATH_ADMINISTRATOR,DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'components'.DIRECTORY_SEPARATOR.'com_acymailing'.DIRECTORY_SEPARATOR.'helpers'.DIRECTORY_SEPARATOR.'helper.php');
 
$joomlaUser = JFactory::getUser();
$newUser = new stdClass();
(!empty($postData['my_form_person_title']['0']) ? $personalTitle = strip_tags($postData['my_form_person_title']['0']) . " " : $personalTitle = "");
(!empty($postData['my_form_name_suffix']['0']) ? $nameSuffix = ", " . strip_tags($postData['my_form_name_suffix']['0']) : $nameSuffix = "");
(!empty($postData['my_form_mname']) ? $middelName = strip_tags($postData['my_form_mname']) . " " : $middelName = "");
$firstName = strip_tags($postData['my_form_fname']) . " ";
$lastName = strip_tags($postData['my_form_lname']);
$newUser->name = $personalTitle . $firstName . $middelName . $lastName . $nameSuffix; // $newUser->name is the concatenation of $personalTitle, $firstName, $middelName, $lastName and $nameSuffix.
$newUser->email = strip_tags($postData['my_form_email']); //This maps the my_form_email field to the ACYMailing email field.
$newUser->city = strip_tags($postData['my_form_city']); // this maps the my_form_city field to the ACYMailing city field.
$newUser->state_or_province = strip_tags($postData['my_form_state_province']['0']); // this maps the my_form_state field to the ACYMailing state field.
$newUser->country = strip_tags($postData['my_form_country']['0']); // this maps the my_form_country field to the ACYMailing country field.
$newUser->zip_postal_code = strip_tags($postData['my_form_zip_p_code']); //This maps the my_form_zip_p_code field to the ACYMailing zip_postal_code field.
$newUser->phone_no = strip_tags($postData['my_form_phone']); //This maps the my_form_phone field to the ACYMailing phone_no field.
if(isset($postData['my_form_interests'])){
  $newUser->contact_me = strip_tags(implode(", ", $postData['my_form_interests'])); //This maps the my_form_interest items to the ACYMailing contact_me items.
}
$newUser->comments = strip_tags($postData['my_form_comments']); //This maps the my_form_comments textarea to the ACYMailing comments text area.
 
$subscriberClass = acymailing_get('class.subscriber');
 
if(!empty($joomlaUser->id)) $newUser->userid = $joomlaUser->id; //If there is a Joomla user logged in, then we link it to the AcyMailing user
                                //we are going to save
$subid = $subscriberClass->save($newUser);
 
$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 list ID 1
 
$newSubscription = array();
if(!empty($subscribe)){
 foreach($subscribe as $listId){
  $newList = array();
  $newList['status'] = 1;
  $newSubscription[$listId] = $newList;
 }
}
$subscriberClass->saveSubscription($subid,$newSubscription);
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!