Can't use shortcode inside shortcode for template

25 November, 2022 19:23:10
mangdev
Topics: 1
Messages: 3
I am trying to make a template to pull User Meta values from the plugin "Ultimate Member - User Meta Shortcode" and output them in the pdf template. i need this to download user profiles using the admin account so user ids need to be dynamic.

The problem is if i use the following shortcodes independently, they work fine, but if i put one inside the other, it breaks.

This Works:
[e2pdf-user key=ID]
[um_user user_id=2 meta_key="first_name"]
2 = random test user id

This doesn't work, i need to pull the user id, and i tried all combinations with quotes:
[um_user user_id=[e2pdf-user key=ID] meta_key="first_name"]

i have tried ....
[um_user user_id="[e2pdf-user key=ID]" meta_key="first_name"]
[um_user user_id='[e2pdf-user key=ID]' meta_key="first_name"]
[um_user user_id="[e2pdf-user key='ID']" meta_key="first_name"]
[um_user user_id='[e2pdf-user key="ID"]' meta_key="first_name"]
i even tried escaping the quotes

it doesn't matter because it always breaks and outputs: blank+meta_key="first_name"

i really this need feature so i can pull data using the user meta plugin, can you help me out?
25 November, 2022 19:59:49
mangdev
Topics: 1
Messages: 3
This works using the code snippet plugin, then i put that shortcode in the template.
Its a lengthy process if i need to make a new snippet for each user meta value, can it be done directly in the template?
25 November, 2022 20:01:18
mangdev
Topics: 1
Messages: 3
Wait nevermind, it takes the current user id not the user profile one, so i do need to find a way to put it in the template.
26 November, 2022 01:47:35
E2Pdf
Support
Topics: 7
Messages: 3345
Hi,

WordPress doesn't allow to use of nested shortcodes in the way it described in 1st post.

1. Inside the E2Pdf Template, you need to use [e2pdf-user] shortcodes which have almost the same functionality as "um_user": it can output user metadata or user custom fields data. We also recommend updating the plugin to the RC version, as it has some improvements in "Visual Mapper" which allows a better way to find needed shortcodes for user: https://e2pdf.com/support/desk/how-to-update-plugin-to-rc-release-candidate-version-from-e2pdf-com

For example, E2Pdf must be able to output the user's "first name" from meta via the current shortcode:

[e2pdf-user key="first_name" meta="true"]

* however we recommend using "Visual Mapper" ("Right Mouse Click" -> "Map" (in field) inside E2Pdf Template) to find correct shortcodes.

2. From the backend you can change the User ID for which it must be generated PDF via "E2Pdf" -> "Export" while exporting, however, if you need to output a user PDF download link on frontend and this link must be generated on a page which connected to the user, you will need to prepare special [e2pdf-download] shortcode and define "user_id" for which it must be generated PDF as E2Pdf can't detect yet automatically MemberPress User IDs.

For example, if you need to output a PDF download link inside Member Profile Template, you must be able to use a PHP snippet or modify the member profile template as follows: https://docs.ultimatemember.com/article/119-overriding-default-ultimate-member-profile-templates

You will need to get user_id by member press and generate a special shortcode with the definition of user_id:

$profile_id = um_profile_id();
echo do_shortcode('[e2pdf-download id="1" dataset="123" user_id="' . $profile_id . '"]’);

* where "1" must be replaced with your E2Pdf Template and "123" must be replaced with any Post ID of the Post Type to which connected E2Pdf Template. You must be able to find the correct value from "E2Pdf" -> "Export".

As you can see $pofile_id will get the Ultimate member ID and it will be assigned to E2Pdf and all [e2pdf-user] shortcodes inside the E2Pdf Template will use this User ID for data rendering.

P.S. If it still will not work as expected, attach please some screenshots of where and how you try to output E2Pdf shortcodes, E2Pdf Template connection, etc. You can mark the message "private" so only we can see the message.

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