gpp_iframe_url_args

  1. Description
  2. Usage
  3. Parameters
  4. Examples
    1. Pass URL parameters from parent page to popup iframe
    2. Pass multiple URL parameters to a specific popup
    3. Add tracking parameters to all popup iframes
  5. Since

Description

Filter the iframe URL arguments. Use this filter to add custom query parameters to the popup iframe URL. These parameters will be available in the iframe context and can be read by Gravity Forms hooks like gform_pre_render.

Usage

Applied globally

add_filter( 'gpp_iframe_url_args', 'my_custom_function' );

Parameters

$feed_id int

The popup feed ID.

$args array

The original arguments passed to get_iframe_url().

Examples

Pass URL parameters from parent page to popup iframe

Pass specific URL parameters from the parent page to the popup iframe so they can be accessed by gform_pre_render or prepopulation.

add_filter( 'gpp_iframe_url_args', function( $url_args, $feed_id, $args ) {
    // Pass the 'example' parameter if it exists on the parent page
    if ( isset( $_GET['example'] ) ) {
        $url_args['example'] = sanitize_text_field( $_GET['example'] );
    }
    return $url_args;
}, 10, 3 );

Pass multiple URL parameters to a specific popup

Only pass parameters to a specific popup feed by checking the feed ID.

add_filter( 'gpp_iframe_url_args', function( $url_args, $feed_id, $args ) {
    // Only apply to popup feed ID 37
    if ( $feed_id !== 37 ) {
        return $url_args;
    }
    // Pass multiple parameters
    $params_to_pass = [ 'race', 'event_id', 'ref' ];
    foreach ( $params_to_pass as $param ) {
        if ( isset( $_GET[ $param ] ) ) {
            $url_args[ $param ] = sanitize_text_field( $_GET[ $param ] );
        }
    }
    return $url_args;
}, 10, 3 );

Add tracking parameters to all popup iframes

Add UTM or other tracking parameters to popup iframes for analytics.

add_filter( 'gpp_iframe_url_args', function( $url_args, $feed_id, $args ) {
    // Pass through all UTM parameters
    foreach ( $_GET as $key => $value ) {
        if ( strpos( $key, 'utm_' ) === 0 ) {
            $url_args[ $key ] = sanitize_text_field( $value );
        }
    }
    return $url_args;
}, 10, 3 );

Since

  • 1.0 Hook added.