Once again thank you for your terrific support.
The code you suggested didn't work but with the help of the developer documentation (
http://www.acyba.com/en/support/documentation/64-acymailing-developer-documentation.html ) for AcyMailing and youguiding me in the right directing I have put together the code below which works perfectly for me but as I am not a programmer I'm sure it can be improved (i.e. read the database to see what lists are available and generate checkboxes etc to allow subscribers to choose, but this goes beyond my present need).
I would appreciate a quick check by netshine if you have a spare moment. If you cant see any major problems I'll post this on Acyba's forum (
http://www.acyba.com/en/support/forum.html ) for anyone else wanting to integrate the 2 components.
Code below added to order form in Submit Code field on Advanced tab.
// CREATE SUBSCRIBER
if(!include_once(rtrim(JPATH_ADMINISTRATOR,DS).DS.'components'.DS.'com_acymailing'.DS.'helpers'.DS.'helper.php')){
return false;
}
$myUser = null;
$myUser->email = $_POST['NBILL_CORE_email_address'];
$myUser->name = $_POST['NBILL_CORE_first_name'].' '.$_POST['NBILL_CORE_last_name']; //this information is optional
$subscriberClass = acymailing::get('class.subscriber');
$subid = $subscriberClass->save($myUser); //this function will return you the ID of the user inserted in the AcyMailing table
// SUBSCRIBE TO LISTS
$subscribe = array(1); //Id of the lists you want the user to be subscribed to (can be empty)
$remove = array(); //Id of the lists you want the user to be removed from (can be empty)
$memberid = $_POST['NBILL_CORE_email_address']; //ID of the Joomla User or user e-mail (this code supposes that the user is already inserted in AcyMailing!)
if(!include_once(rtrim(JPATH_ADMINISTRATOR,DS).DS.'components'.DS.'com_acymailing'.DS.'helpers'.DS.'helper.php')){
echo 'This plugin can not work without the AcyMailing Component';
return false;
}
$userClass = acymailing::get('class.subscriber');
$newSubscription = array();
if(!empty($subscribe)){
foreach($subscribe as $listId){
$newList = null;
$newList['status'] = 1;
$newSubscription[$listId] = $newList;
}
}
if(!empty($remove)){
foreach($remove as $listId){
$newList = null;
$newList['status'] = 0;
$newSubscription[$listId] = $newList;
}
}
if(empty($newSubscription)) return; //there is nothing to do...
$subid = $userClass->subid($memberid); //this function returns the ID of the user stored in the AcyMailing table from a Joomla User ID or an e-mail address
if(empty($subid)) return false; //we didn't find the user in the AcyMailing tables
$userClass->saveSubscription($subid,$newSubscription);