Skip Navigation

[Resolved] Genrate a PDF

This support ticket is created 4 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 10 replies, has 2 voices.

Last updated by Waqar 4 years, 5 months ago.

Assisted by: Waqar.

Author
Posts
#1387465

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

#1387467

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

#1387655

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

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

#1387975

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.

#1388003

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

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

#1392457

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;
}

#1392961

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

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

#1393295

My issue is resolved now. Thank you!

#1393307

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.

#1393313

Thanks for your help Waqar!

#1393957

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

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

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.