Integrate Fabrik with Acymailing 7

Procom

New Member
Hello,

I am using Fabrik for a while with plenty of forms that are conected to acymailing 5, so each time someone post a form, his name and email are added in specific lists of Acymailing.

Until now, I could have it working using a redirect plugin on form validation with such a link :

Code:
index.php?option=com_acymailing&ctrl=sub&task=optin&hiddenlists=1,2&user[firstname]={your_firstname_fk}&user[name]={your_name_fk}&user={your_email_fk}&redirect=https://www.mywebsite.com/thanks-page.html

Now with Acymailing 7, it is recommended to use PHP to get the data from Fabrik and put them in Acymailing suscriber list.

They provide a documentation as exemple with RS Form :

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['EMAIL_FIELD']);
$myUser->name = strip_tags($postData['NAME_FIELD']);

// If the user already exists update it
$existingUser = $userClass->getOneByEmail($postData['EMAIL_FIELD']);
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 = true; // 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
$subscribe = [2,5,6]; // Ids of the lists you want the user to be subscribed to need to be added in this array
$userClass->subscribe($userId, $subscribe);
In this code, CUSTOM_FIELD_ID is the ID that can be seen in the Acy custom fields listing.

EMAIL_FIELD, NAME_FIELD and MY_FIELD must be replaced by your form's field names, so in this example it would be "Email", "the user name" and "Our newsletters field name":

I tried to adapt it to Fabrikar, replacing the IDs and field name with mine, with "onAfterProcess" option, but my form don't catch the data to Acymailing susciber list.

Did someone already achieve to get this integration working?
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top