I have a Custom Post Type called "Profile". With Advanced Custom Fields (ACF) I've added the additional field PDF_file , which is used to upload a file to the newly created post, and on the frontend is a button linked to the uploaded file.
Using Gravity Forms I want visitors to be able to send this file to a friend by sending the file link, which is basically the value of the " PDF_file " field.
I can't seem to find out how I can retreive the value and insert it in to the Gravity Form.
I have implemented the Gravity in the single custom post type template by using:
<?php gravity_form(15, $display_title=false, $display_description=true, $display_inactive=false, $field_values=null, $ajax=true, $tabindex); ?>
Your best bet it is to populate the URL of the field (which I assume is stored in the ACF custom field) into a hidden field on your Gravity Form. The easiest way to accomplish this is with "dynamic population".
http://www.gravityhelp.com/documentation/page/Using_Dynamic_Population
In your case, I would recommend going with the "hook" method.
add_filter( 'gform_field_value_your_parameter', 'my_custom_population_function' );
function my_custom_population_function( $value ) {
global $post;
return function_exists( 'get_field' ) ? get_field( 'PDF_file', $post->ID ) : false;
}
You can update your_parameter
in the filter name to whatever you'd like to call the parameter. Just make sure you populate that parameter name in the dynamic population "Parameter Name" input on the field settings for your hidden field.
I have had some success with this:
add_filter( 'gform_field_value_job_ref', 'gf_filter_job_ref' );
function gf_filter_job_ref() {
return esc_attr( get_field( 'job_ref' ) );
}
Ensure that your hidden field is set named 'job_ref' (in this case) and that the advanced > parameter field is also 'job_ref'.
Thanks go to this blog post: http://www.engagewp.com/create-invoices-gravity-forms-wordpress/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.