Using own Shortcodes

WordPress Scheduled
20 October, 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
20 October, 2020 14:19:51
E2Pdf
Support
Topics: 7
Messages: 3335
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!
21 October, 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?
21 October, 2020 09:42:17
E2Pdf
Support
Topics: 7
Messages: 3335
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!
21 October, 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
21 October, 2020 10:25:13
E2Pdf
Support
Topics: 7
Messages: 3335
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!
21 October, 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!
21 October, 2020 15:19:28
E2Pdf
Support
Topics: 7
Messages: 3335
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!
25 October, 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]"
25 October, 2020 13:31:55
E2Pdf
Support
Topics: 7
Messages: 3335
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!
25 October, 2020 13:53:27
E2Pdf
Support
Topics: 7
Messages: 3335
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!