1. Fabrik 3.9 has been released. If you have updated Joomla to 3.9, this is a required update.
    Dismiss Notice

Integrate Fabrik with Acymailing 7

Discussion in 'Community' started by Procom, Feb 26, 2021.

  1. Procom

    Procom New Member

    Level: Community
    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 (Text):
    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 (Text):

    // 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);
     
    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?
     
  2. juuser

    juuser Well-Known Member

    Level: Community
    How does your exact code look like with replaced id's and field names?
     

Share This Page