Gform update meta

Description

Updates the meta value of the specified meta key in the Entry Meta table. If the specified meta key does not exist, it will be created.

Usage


gform_update_meta($entry_id, $meta_key, $meta_value);

Parameters

entry_id
(integer) The ID of the entry.
meta_key
(string) The meta key of the meta value you wish to update.
meta_value
(string) The value to be set as the new value for the specified meta key.

Examples

This example sets a meta value for the returned confirmation value from a call to a fictional API on post submission.


add_action('gform_post_submission', 'send_to_api');
function send_to_api($entry) {
    
    // prepare entry details for third party API
    $lead_details = array('id' => $entry['id'], 'first_name' => $entry[1], 'last_name' => $entry[2]);
    
    // send to the third party API
    $response = process_lead($lead_details);
    
    // add response value to entry meta
    gform_update_meta($entry['id'], 'api_response', $response);
    
}

Source Code

This function is located in forms_model.php

Search the Documentation