Last active
November 30, 2015 04:16
-
-
Save mandiwise/ed7cf3209655d122fda0 to your computer and use it in GitHub Desktop.
Auto-populate page title of previously-viewed page in a Gravity Form field
This file contains hidden or 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 | |
function awi_autopopulate_workshop_title( $value ){ | |
$referer_id = url_to_postid( wp_get_referer() ); | |
$workshop_title = get_the_title( $referer_id ); | |
return $workshop_title; | |
} | |
add_filter( 'gform_field_value_workshop_title', 'awi_autopopulate_workshop_title' ); | |
// Usage: | |
// Add code to functions.php or similar | |
// Under "Advanced" tab for the given field in the GF UI, tick the "Allow field to be populated dynamically" box | |
// Add "workshop_title" (no quotes) to the "Parameter Name" input |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment