jvstratum
OK, please read the comment of JSN Uniform:
Hi,
I'm not familiar to AcyMailing. In this case, please contact to AcyMailing provider and confirm that the code works fine with AcyMailing. If the code is correct and it does not run with JSN Uniform , then please let me know
Thank you
So could you please verify the code.
// Load the AcyMailing library
$postData = $_REQUEST['form'];
$ds = DIRECTORY_SEPARATOR;
include_once rtrim(JPATH_ADMINISTRATOR, $ds).$ds.'components'.$ds.'com_acym'.$ds.'helpers'.$ds.'helper.php';
$userClass = new AcyMailing\Classes\UserClass();
// Build the user based on your form's fields
$myUser = new stdClass();
$myUser->email = strip_tags($postData['E-Mail']);
$myUser->name = strip_tags($postData['Last Name']);
// If the user already exists update it
$existingUser = $userClass->getOneByEmail($postData['E-Mail']);
if (!empty($existingUser)) $myUser->id = $existingUser->id;
// You can add as many extra fields as you want if you already created them in AcyMailing
$customFields = [];
$customFields[CUSTOM_FIELD_ID] = $postData['MY_FIELD']; // the custom field id can be found in the Custom fields list of the AcyMailing admin page
$userClass->sendConf = false; // Or false if you don't want a confirmation email to be sent
$userId = $userClass->save($myUser, $customFields);
// The user now exists in AcyMailing, let's add some list subscriptions
if (!empty($postData['37[]']) && $postData['37[]'] === 'Yes') {
$subscribe = [2]; // Ids of the lists you want the user to be subscribed to need to be added in this array
$userClass->subscribe($userId, $subscribe);
}
Thank you very much!