Skip to main content

is this "createOrUpdate()" API available only for Pro version?

I want to use company create method to create company in fluentCRM via custom code once company created in fluent forms, this is my current code:

add_action('acf/save_post', 'sync_company_with_fluentcrm', 20);

function sync_company_with_fluentcrm($post_id) {
    if (get_post_type($post_id) !== 'company') return;

    // read ACF data
    $data = [
        'name'     => get_field('company-name', $post_id),
        'email'    => get_field('company-email', $post_id),
        'phone'    => get_field('company-phone', $post_id),
        'website'  => get_field('company-url', $post_id),
        'vat_number' => get_field('company-vat', $post_id),
        'owner_id' => get_post_field('post_author', $post_id),
    ];

    // API used
    $companyApi = FluentCrmApi('companies');
    $company = $companyApi->createOrUpdate($data);

    if ($company && $data['owner_id']) {
        // connect owner with contact
        $companyApi->attachContactsByIds([$data['owner_id']], [$company->id]);
    }
}

No, company module is available in Free version.

Radovan Bryx

Shiam ChowdhuryΒ Thanks Shiam. Unfortunately the code upwards does not work, but will try somehow to manage this. Is there some guideline what should be enabled in settings or what is the righ approach how to call this method? Thanks in advance

Radovan BryxΒ we doesn't have any column named 'vat_number' in our database table. I guess this is creating issue.

Radovan Bryx

Or why there is no option to create new company via fluent forms like using automation? Shiam ChowdhuryΒ Β Use case I need to manage: user can create new company on my web via fluent forms. Once created i want to add this company also to fluentCRM and assing current user to the company... Is there any other way?