Showing checkbox values in print-out

WordPress
23 September, 2020 11:44:01
meadmin
Topics: 2
Messages: 2
I have attached an example. We have a form, where some questions are answered by selecting one or more checkboxes. Those values are being stored in the database as arrays. E2PDF appears to be just printing what is in the database instead of the reader-friendly values. How can we configure it to use the reader-friendly values?

We created the form using Toolset in WordPress.
24 September, 2020 02:39:04
E2Pdf
Support
Topics: 7
Messages: 3163
Unfortunately E2Pdf has not yet native support of Toolset, however it must be possible to solve such task of 1 by the following ways:

E2Pdf currently can navigate via arrays by using "path" attribute on shortcode. To accomplish it with this way you must create "textarea" inside PDF with shortcode that outputs serialized value, as example we will be using: [meta key="wpcf-checkbox-1"]

When you get serialized array you must unserialize it via services like: https://www.unserialize.me/.

In our case serialized value looks like:
a:2:{s:64:"wpcf-fields-checkboxes-option-ed2aa5d6f07e8805136cc5f32f3e77ba-1";a:1:{i:0;s:1:"1";}s:64:"wpcf-fields-checkboxes-option-d41ae1e90e0cdc01acdbc9eb2eb9ab87-1";a:1:{i:0;s:1:"1";}}

So after unserialize operation we get the path to navigate, (dot (.) must be used as delimiter between array keys), it's if you need to output values separately:

[meta key="wpcf-checkbox-1" path="wpcf-fields-checkboxes-option-ed2aa5d6f07e8805136cc5f32f3e77ba-1.0"]
[meta key="wpcf-checkbox-1" path="wpcf-fields-checkboxes-option-d41ae1e90e0cdc01acdbc9eb2eb9ab87-1.0"]

However if you need to output all values in one line, you will need to use custom function filter, which must be added to functions.php to get the list of checkboxes values and "implode" them.

Function example that must be added to functions.php: https://codeshare.io/Gbbl0w

P.S. Keep attention that it must be changed "key" to yours.

We remain at your service.
We would really appreciate your feedback at WordPress.org!