Created
May 4, 2016 14:16
-
-
Save barrykooij/73abb6c681d5e5451ae16ecbb7c0f5e7 to your computer and use it in GitHub Desktop.
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
// Gravity Forms Dynamic Redirect | |
add_filter( 'gform_confirmation', 'dlm_gf_dynamic_redirect', 10, 4 ); | |
function dlm_gf_dynamic_redirect( $confirmation, $form, $entry, $ajax ) { | |
// DLM GF Handler | |
$dlm_gf_handler = new DLM_GF_Gravity_Forms_Handler(); | |
// fetch download ID dynamically from form | |
$lead_id = $dlm_gf_handler->get_lead_index_of_dlm_field( $form ); | |
// check | |
if ( null !== $lead_id ) { | |
if ( isset( $entry[ $lead_id ] ) ) { | |
$download_id = absint( $entry[ $lead_id ] ); | |
// create download | |
$download = new DLM_Download( $download_id ); | |
// check URL | |
if ( '' != $download->get_the_download_link() ) { | |
// set redirect | |
$confirmation = array( 'redirect' => $download->get_the_download_link() ); | |
} | |
} | |
} | |
return $confirmation; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment