Search code examples
gravity-forms-plugin

gform_get_meta and wp_rg_lead_meta are empty


I'm trying to use https://docs.gravityforms.com/gform_get_meta/ API to get the Zoho CRM inserted ID using 'zohocrm_contact_id' as the meta key.

But, I get a false response and When I look at the wp_rg_lead_meta table, it is empty. Any Idea why this is happening and How to rectify it? Below is my PHP code for your reference

$my_form_id = '1';
$search_criteria = array();
$search_criteria['field_filters'][] = array( 'key' => '3', 'value' => 
$_POST['email']);
$form_data = GFAPI::get_entries( $my_form_id , $search_criteria );
$meta_value = gform_get_meta( $form_data[0]['id'], 'zohocrm_contact_id' 
);//entry_id is 43
echo $meta_value;//false

Solution

  • I would like to answer my own question from the answer I got from Grav Form priority support.

    The GFAPI::add_entry method only adds the entry directly to the database, it does not trigger any add-on integrations. If you need the Zoho add-on integration to be triggered you would need to use the GFAPI::submit_form method or manually trigger feed processing for the entry like so:

    $entry_id = GFAPI::add_entry($data);
    if ( ! is_wp_error( $entry_id ) && function_exists( 'gf_zohocrm' ) ) {
        $entry = GFAPI::get_entry( $entry_id );
        $form = GFAPI::get_form( $entry['form_id'] );
        gf_zohocrm()->maybe_process_feed( $entry, $form );
    }