Skip to content

Instantly share code, notes, and snippets.

@mandiwise
Last active November 30, 2015 04:16
Show Gist options
  • Save mandiwise/ed7cf3209655d122fda0 to your computer and use it in GitHub Desktop.
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
<?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