Skip to content

Instantly share code, notes, and snippets.

@billerickson
Last active April 18, 2017 16:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save billerickson/409099c9355cfc337867c690a703c7ab to your computer and use it in GitHub Desktop.
Save billerickson/409099c9355cfc337867c690a703c7ab to your computer and use it in GitHub Desktop.
<?php
/**
* WPForms, eBook Download URL
*
* @author Bill Erickson
* @see http://www.billerickson.net/code/wpforms-ebook-download-url
*/
function ea_wpforms_ebook_download_url( $string, $form_data = array(), $fields = array(), $entry_id = false ) {
if( ! $entry_id )
return;
$download = get_post_meta( get_the_ID(), 'ea_wpforms_ebook_download_url', true );
if( $download )
$string = str_replace( '{download}', wp_get_attachment_url( $download ), $string );
return $string;
}
add_filter( 'wpforms_process_smart_tags', 'ea_wpforms_ebook_download_url', 20, 4 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment