Using Gravity Forms ‘gform_post_save_feed_settings’ PHP action

The gform_post_save_feed_settings Gravity Forms action allows you to perform custom actions when a feed is saved.

Usage

add_action('gform_post_save_feed_settings', 'your_custom_function', 10, 4);

function your_custom_function($feed_id, $form_id, $settings, $addon) {
    // Your custom code here
    return $feed_id;
}

Parameters

  • $feed_id (string): The ID of the feed which was saved.
  • $form_id (int): The current form ID associated with the feed.
  • $settings (array): An array containing the settings and mappings for the feed.
  • $addon (GFAddon): The current instance of the GFAddOn object which extends GFFeedAddOn or GFPaymentAddOn (i.e. GFCoupons, GF_User_Registration, GFStripe).

More information

See Gravity Forms Docs: gform_post_save_feed_settings

This action was introduced in Gravity Forms v2.4.12.3 and is located in the class-gf-feed-addon.php file.

Examples

Log feed settings update

Log the updated feed settings when a feed is saved.

add_action('gform_post_save_feed_settings', 'log_feed_settings_update', 10, 4);

function log_feed_settings_update($feed_id, $form_id, $settings, $addon) {
    error_log("Feed ID {$feed_id} for form ID {$form_id} has been updated.");
}

Send notification on feed update

Send an email notification when a feed is updated.

add_action('gform_post_save_feed_settings', 'send_notification_on_feed_update', 10, 4);

function send_notification_on_feed_update($feed_id, $form_id, $settings, $addon) {
    $to = '[email protected]';
    $subject = 'Feed Updated';
    $message = "Feed ID {$feed_id} for form ID {$form_id} has been updated.";
    wp_mail($to, $subject, $message);
}

Add custom data to feed settings

Add custom data to the feed settings when a feed is saved.

add_action('gform_post_save_feed_settings', 'add_custom_data_to_feed_settings', 10, 4);

function add_custom_data_to_feed_settings($feed_id, $form_id, $settings, $addon) {
    $settings['custom_data'] = 'Your custom data';
    GFAPI::update_feed($feed_id, $settings);
}

Delete related data when a feed is updated.

add_action('gform_post_save_feed_settings', 'delete_related_data_on_feed_update', 10, 4);

function delete_related_data_on_feed_update($feed_id, $form_id, $settings, $addon) {
    // Delete related data from your custom table or options
}

Update feed conditionally

Update the feed settings conditionally based on the form ID.

add_action('gform_post_save_feed_settings', 'conditionally_update_feed', 10, 4);

function conditionally_update_feed($feed_id, $form_id, $settings, $addon) {
    if ($form_id == 5) {
        $settings['custom_setting'] = 'Your custom value';
        GFAPI::update_feed($feed_id, $settings);
    }
}