GithubHelp home page GithubHelp logo

mayurjobanputra / gravity-to-fluentcrm Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 21 KB

Use this handy script to copy submissions from Gravity to your FluentCRM installation

License: GNU General Public License v3.0

PHP 100.00%

gravity-to-fluentcrm's Introduction

Gravity Forms to FluentCRM Integration

This PHP snippet enables automatic synchronization of form submissions from Gravity Forms to FluentCRM. When a user submits a form, their details are added or updated in a FluentCRM contact list.

Prerequisites

  • WordPress website with Gravity Forms and FluentCRM (free version is sufficient) installed and activated.
  • Basic understanding of PHP and WordPress hooks.

Installation

  1. Locate Your Form and Field IDs:

    • In your WordPress dashboard, navigate to Gravity Forms and note the ID of the form you want to integrate.
    • Identify the IDs of the fields for 'Name' and 'Email' in your Gravity Forms form.
  2. Edit the PHP Snippet:

    • Open the PHP file or copy the code provided below.
    • Replace 'name_field_id' and 'email_field_id' with the actual field IDs from your form.
    • Replace '1' in add_action and 'lists' array with your Gravity Form ID and FluentCRM list ID, respectively.
  3. Add the Code to Your WordPress Site:

    • Add the edited code to your theme's functions.php file or a custom plugin.

Code Snippet

// Hook into Gravity Forms submission for a specific form. Replace '1' with your form ID.

add_action( 'gform_after_submission_1', 'add_subscriber_to_fluentcrm', 10, 2 );

function add_subscriber_to_fluentcrm( $entry, $form ) {
    // Initialize the FluentCRM API for managing contacts. This creates an instance
    // for interacting with the contacts module in FluentCRM.
    $contactApi = FluentCrmApi('contacts');

    $full_name = rgar( $entry, 'name_field_id' ); // Replace 'name_field_id' with your field ID
    $email = rgar( $entry, 'email_field_id' ); // Replace 'email_field_id' with your field ID

    // Split the full name into an array of words separated by spaces.
   $name_parts = explode(' ', $full_name);
   
   // Assign the first word of the name as the first name.
   $first_name = $name_parts[0];
   
   // If there are more words after the first name, combine them as the last name. 
   // If only one word is present, the last name remains empty.
   $last_name = count($name_parts) > 1 ? implode(' ', array_slice($name_parts, 1)) : '';


    $data = [
        'first_name' => $first_name,
        'last_name' => $last_name,
        'email' => $email,
        'status' => 'subscribed',
        'lists' => [1] // Replace '1' with your FluentCRM list ID
    ];

    $contact = $contactApi->createOrUpdate($data);
}

Notes

  • Test the integration in a staging environment before applying it to a live website.
  • Ensure compliance with data protection regulations when handling user data.
  • This script is intended for use with the free version of FluentCRM. Functionality may vary with different versions.

Contributing

Feel free to fork this repository and submit pull requests or issues if you have suggestions or find bugs.

License

This script is open-sourced software licensed under the MIT license.

gravity-to-fluentcrm's People

Contributors

mayurjobanputra avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.