Using own Shortcodes

WordPress Scheduled
October 20, 2020 13:57:17
eingetragen
Topics: 1
Messages: 4
Hey guys,

i wondered if its possible to use my own shortcodes? I tried to get a single page to be printed in the same layout across all browsers – but it didnt work. So I decided to use your plugin to style a PDF.

I habe different Shortcodes:

For example [tischnummer] which outputs a normal text.

Or [logo_user] which outputs something like this: <img src="hwp-content/uploads/2020/10/logo.png" class="drucklogo" style="width:250px; height: auto" /

How can I get my own shortcodes to work?

Thanks for help
October 20, 2020 14:19:51
E2Pdf
Topics: 7
Messages: 3617
Support
Hi,

Actually it must not be any issues using custom shortcodes. You can just put it manually by "Dbl click" (for fields and html object) or set it directly via "Right Mouse Click" -> "Properties" -> "Value" (for "Image" object) for example. By default image object can extract "src" automatically.

We remain at your service.

We would really appreciate your feedback at WordPress.org!
October 21, 2020 09:29:18
eingetragen
Topics: 1
Messages: 4
Ok, but some Shortcodes are not working.

For example this one:


add_shortcode('logo_user', 'logo_user');
function logo_user() {
$user_id = get_current_user_id();
$logo_image= get_field('nutzerlogo', 'user_'. $user_id );
$groesse= get_field('logogrose', 'user_'. $user_id );
$image_size = 'large';
$image_url = $logo_image['sizes'][$image_size];
$outputklein = '<img src="'.$image_url.'" class="drucklogo" style="width:150px; height: auto;" />';
$outputmittel = '<img src="'.$image_url.'" class="drucklogo" style="width:220px; height: auto;" />';
$outputgross = '<img src="'.$image_url.'" class="drucklogo" style="width:260px; height: auto;" />';
$fallback = '<img src="https://eingetragen.com/wp-content/uploads/2020/10/logo.png" class="drucklogo" style="width:220px; height: auto" />';

if ($image_url) {

if ($groesse=="klein") {
return $outputklein;
}
elseif ($groesse=="mittel") {
return $outputmittel;
}
elseif ($groesse=="gross") {
return $outputgross;
}

}

else {
return $fallback;
}
}


It shows just an empty field ... could you please help?
October 21, 2020 09:42:17
E2Pdf
Topics: 7
Messages: 3617
Support
Hi,

We just copied function to child theme functions.php and it fired like expected (screenshots attached).

Did you add this function to theme functions.php or you are using some plugins like (PHP Snippet)? If you are using plugin, did you set to fire function "everywhere" (not only backend, frontend, etc?)

Can you also please attach screenshot of E2Pdf Field setup ("Right Mouse Click" -> "Properties")?

We would really appreciate your feedback at WordPress.org!
October 21, 2020 10:21:13
eingetragen
Topics: 1
Messages: 4
We did it via functions .php – wenn i Download the file on a subpage the [logousr] shortcode is just blank
October 21, 2020 10:25:13
E2Pdf
Topics: 7
Messages: 3617
Support
You are using "HTML" object which has less size then image and as a result it truncated. If you need this image separately use please "Image Object" or make "HTML" object size bigger. For testing work of shortcodes it's recommended to use "textarea".

We remain at your service.

We would really appreciate your feedback at WordPress.org!
October 21, 2020 13:35:20
eingetragen
Topics: 1
Messages: 4
Ok, thank you. All of the Shortcodes are working now!

Except of the most important one. I increased the field height as you recommended, but still there is no QR Code within the PDF file.

[kaya_qrcode_dynamic ecclevel="L" align="alignnone"][usrqr][/kaya_qrcode_dynamic]

This code makes a QR-Code from the Link delivered within [usrqr] – but when I use the HTML field it doesnt show in the PDF file. When I use textarea, there is some HTML code printed in the PDF file. Please see the file attached.

Thanks for your great support!
October 21, 2020 15:19:28
E2Pdf
Topics: 7
Messages: 3617
Support
Regarding plugin support forum https://wordpress.org/support/topic/gravity-pdf-support/ plugin renders QR Code via JavaScript so unfortunately it will not work with E2Pdf as it must be generated Image Url to show it inside PDF.

As a solution you can try to use https://wordpress.org/plugins/barcode-qrcode-generator/ however it still will require some additional coding to output generated image.

1. You need to create "Image" object with [usrqr] (Screenshot 1) as value inside E2Pdf Template and get its Element ID (Screenshot 2)

2. Add filter to functions.php https://codeshare.io/GbBdWw and change $template_id and $element_id to yours.

Or use another plugin which can output QR Code Image URL.

We remain at your service.

We would really appreciate your feedback at WordPress.org!
October 25, 2020 13:07:28
schwab
Topics: 2
Messages: 10
I dont no what happend, your solution worked for me.
But now im getting an error:

[ERROR] NumberFormatException: For input string: "[usrqr]"
October 25, 2020 13:31:55
E2Pdf
Topics: 7
Messages: 3617
Support
Hi,

Can you please attach backup of E2Pdf Template to the next message please? (Screenshot attached).

P.S. You can mark message private so only we can see the message.

We would really appreciate your feedback at WordPress.org!
October 25, 2020 13:53:27
E2Pdf
Topics: 7
Messages: 3617
Support
It looks like you set background mistakenly as "[usrqr]" on "So geht's" element. So fixing "background" value must solve issue. You must be able just to click on background and remove it from there. We will add check for valid value in next release to not throw error upon PDF generation.

We remain at your service.

We would really appreciate your feedback at WordPress.org!
Get News and Updates
Our monthly newsletter keeps you in the loop, so you'll always be up to date with the latest news and updates about E2Pdf.
* You can update your email subscription preferences here.
All trademarks, service marks, trade names, product names, and logos appearing on this website are the property of their respective owners. The use of trademarks such as Formidable Forms®, Forminator Forms®, Gravity Forms®, JetFormBuilder®, WordPress®, WooCommerce®, WPForms® and others is solely for identification purposes (nominative use) and does not imply any affiliation, sponsorship, or endorsement by the respective trademark holders.
© 2017 - 2026, https://e2pdf.com

We use cookies to collect and analyse information on site performance and usage, to provide social media features and to enhance and customise content and advertisements. By clicking "Accept Selected", you consent to use of selected cookies according to our Cookie Policy.