Tell us what you are trying to do? Generate a printable PDF Membership Certificate
Is there any documentation that you are following? hidden link
Is there a similar example that we can see? Not that I am aware of
What is the link to your site? hidden link
The plugin that I am looking at does have ACF compatibility. Can it be used with Types?
Compatible with ACF | Advanced Custom Fields Plugin for WordPress
Hi Cristian,
Thank you for contacting us and I'd be happy to assist.
The "WP Advanced PDF" plugin officially lists compatibility with the "Advanced Custom Fields", but if it supports standard custom fields, it can also be used with the custom fields added by the Toolset Types plugin.
For example, the plugin's documentation page mentions that it offers a filter "the_post_export_content" to customize the content of the generated PDFs.
( https://wordpress.org/plugins/wp-advanced-pdf/#how%20can%20i%20change%20the%20content%20pdf%20document%20%3F )
This means that Types Fields API ( https://toolset.com/documentation/customizing-sites-using-php/functions/ ) can be used to get the values of the desired custom fields and then they can be used in the PDF's content.
I hope this helps and please let me know if you need any further assistance around this.
regards,
Waqar
Thank you, Waqar, I am going to start developing this and I might get stuck. Particularly writing the custom function that ties both plugins together. I am guessing that I would write a filter hook that would bring the Types data through en "echo PHP" function.
Hi Cristian,
Thanks for writing back and you're thinking on the right lines.
If you face any difficulty in getting the data through Types Fields API, you're welcome to write to us and we'll be happy to point in the right direction.
regards,
Waqar
Just like I suspected. I am having issues writing the combined code. Basically nesting the echo command within the function.
I attempted this, but it is not working.
add_filter( 'the_post_export_content', custom_function );
function custom_function( $post_content ){
$my_content = '<p style="text-align:center;">This Certificate is issued to' ?> <?php echo types_render_field ('wpcf-cutomer-name', array('raw' => 'true','output'=> null,'show_name' => 'false')) ?>'</p>';
$more_content = '<p> Velit repudiandae earum ducimus odit excepturi cum laboriosam.</p>';
return $my_content . $more_content;
}
Hi Cristian,
I noticed that some of the attributes used in your code for the "types_render_field" function are not supported.
Please only include the attributes which are listed in the documentation:
https://toolset.com/documentation/customizing-sites-using-php/functions/
Also, you can simplify the content generation using "concatenation":
hidden link
Example:
add_filter( 'the_post_export_content', 'custom_function' );
function custom_function( $post_content ){
$customer_name = types_render_field('cutomer-name', array('output' => 'raw'));
$my_content = '<p style="text-align:center;">This Certificate is issued to '.$customer_name.'.</p>';
$more_content = '<p> Velit repudiandae earum ducimus odit excepturi cum laboriosam.</p>';
return $my_content . $more_content;
}
Please note how the value from the custom field is first saved in a variable and then that variable is called in the content.
Also the "wpcf-" prefix shouldn't be used in the "types_render_field" function.
regards,
Waqar
My issue is resolved now. Thank you!
Waqar, thank you so much. But I have one last question. How can I bring the value of a Taxonomy?
The memberships are divided by taxonomies and I would like to pull the taxonomies name also.
Thanks for your help Waqar!
Hi Cristian,
Thanks for the update and glad that it worked.
To get the attached taxonomy terms, you can use the "wpv-post-taxonomy" shortcode from the views plugin:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-post-taxonomy
Example:
[wpv-post-taxonomy type="category" separator=", " format="name"]
In your PHP code, you can use this shortcode through the "do_shortcode" function:
https://developer.wordpress.org/reference/functions/do_shortcode/
Example:
$taxonomy_names = do_shortcode('[wpv-post-taxonomy type="category" separator=", " format="name"]');
I hope this helps and for a new question/concern, please open a new ticket.
regards,
Waqar