Update Other Entry on Submission

Update a field value of an entry on Form A when Form B is submitted based on populated Easy Passthrough token.

This technique provides a secure way to allow users to modify specific information on a previous entry without exposing an entry ID. Exposing the entry ID can be a security risk as it is highly predictable, potentially allowing bad actors to act on entries that do not belong to them.

Note: this is very similar to our GPEP Edit Entry snippet. The key difference is the GPEP Edit Entry snippet is intended to update entries using the same form that they were submitted from, while this snippet is intended to provide a more surgical approach, updating only specific values on the original entry based on the submission of a separate form.

Instructions

  1. Add a Hidden field to Form B that will be used to capture an Easy Passthrough token.

  2. Configure an Easy Passthrough feed on Form B to map data from Form A.

  3. In the “Map Entry Meta” section, map the “Easy Passthrough Token” from Form A to the field you’ve created to capture it on Form B.

  4. Install and configure this snippet per the inline instructions.

Code

Filename: gpep-update-other-form-entry-by-ep-token.php

<?php
/**
 * Gravity Perks // Easy Passthrough // Update Other Entry on Submission
 * https://gravitywiz.com/documentation/gravity-forms-easy-passthrough/
 *
 * Instruction Video: https://www.loom.com/share/65fad5b264e640ab94dca058d6ba83f4
 *
 * Update a field value of an entry on Form A when Form B is submitted based on populated
 * Easy Passthrough token.
 *
 * This technique provides a secure way to allow users to modify specific information on a previous
 * entry without exposing an entry ID. Exposing the entry ID can be a security risk as it is highly
 * predictable, potentially allowing bad actors to act on entries that do not belong to them.
 *
 * Note: this is very similar to our [GPEP Edit Entry](https://gravitywiz.com/edit-gravity-forms-entries-on-the-front-end/)
 * snippet. The key difference is the GPEP Edit Entry snippet is intended to update entries using the
 * same form that they were submitted from, while this snippet is intended to provide a more surgical
 * approach, updating only specific values on the original entry based on the submission of a separate form.
 *
 * Instructions
 *
 * 1. Add a Hidden field to Form B that will be used to capture an Easy Passthrough token.
 *
 * 2. Configure an Easy Passthrough feed on Form B to map data from Form A.
 *
 * 3. In the "Map Entry Meta" section, map the "Easy Passthrough Token" from Form A to the
 *    field you've created to capture it on Form B.
 *
 * 4. Install and configure this snippet per the inline instructions.
 */

// Update "123" to the form ID that should trigger an update to the other form's entry.
add_action( 'gform_after_submission_123', function ( $entry, $form ) {
	// Update "4" to the ID of the field that is populated with the EP token.
	$token_field_id = 4;

	// Update "5" to the ID of the field that should be updated on the other form's entry.
	$target_field_id = 5;

	// Update "Canceled" to the value that should be updated on the other form's entry.
	$update_value = 'Canceled';

	$token        = $entry[ $token_field_id ];
	$source_entry = gp_easy_passthrough()->get_entry_for_token( $token );
	if ( $source_entry ) {
		$source_entry[ $target_field_id ] = $update_value;
		GFAPI::update_entry( $source_entry );
	}

}, 10, 2 );

Comments

  1. Ignacio
    Ignacio March 26, 2025 at 10:56 pm

    Hello, thanks for the great snippet and plugins. My Pro license is out of support for a few months now but may I ask, would it be possible to re-trigger the feeds on the updated entry? I have a connect wp-db plugin feed on the to be updated entry, it sends entry data to a mysql table when the form is submitted. They are connected with a key in such a way that if the entry gets updated either via normal GF edit entry or with the Easy Passthrough-on-same-form editing trick the database table gets updated as well. However I noticed that using this snippet the values won’t get updated after the entry is updated, which I asume has to do with the snippet not triggering the wp-db connect feed for the updated entry. Thanks, Ignacio

    Reply
    1. Samuel Bassah
      Samuel Bassah Staff March 27, 2025 at 5:25 am

      Hi Ignacio,

      Yes, it is possible to modify the snippet to re-trigger feeds when an entry is updated, but it would require some customization. Since support and customization requests require an active license, we’d need you to submit this request via our support form. If you decide to renew your Pro license, you’ll be able to access support and we’d be happy to assist further. Let us know if you have any other questions!

      Best,

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.