Last active
August 8, 2018 09:41
-
-
Save justinswelch/a33ecc65c06de1372aa650ffd7cd071a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/*------------------------------------------------ | |
Track email click from GF notification | |
The link in the GF notification would use form entry values as query vars like: | |
<a href="https://example.com/confirmation-page/?rsvp=1&eid={entry_id}"> Click here to RSVP</a> | |
The full GF notification url the user clicks looks like: | |
https://example.com/confirmation-page/?rsvp=1&&eid=1 | |
------------------------------------------------ | |
Function to make shortcode to insert on GF | |
verification page. Checks for query string "rsvp=1", | |
and if that's set, use the entry id to know which | |
entry's hidden rsvp field to update. | |
Usage of shortcode: [gravity_verify_rsvp] | |
------------------------------------------------*/ | |
function shortcode_gf_verify_rsvp( $atts = array() ) { | |
/*-------------------------------------------- | |
* Check if verification param is in the url | |
*--------------------------------------------*/ | |
if( isset( $_GET[ 'rsvp' ] ) && $_GET[ 'rsvp' ] == 1 ) { | |
$entry_id = $_GET[ 'eid' ]; | |
$input_id = 3; // hidden field id for rsvp | |
$value = 'yes'; // default is no - change to yes to rsvp | |
// Attempt to update hidden verification field | |
$verified = GFAPI::update_entry_field( $entry_id, $input_id, $value ); | |
// If successful... | |
if( $verified ) { | |
return "Thanks for your RSVP!"; | |
} | |
} | |
} | |
add_shortcode( 'gravity_verify_rsvp', 'shortcode_gf_verify_rsvp' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment