Skip Navigation

[Resolved] How to generate document based on variable user meta?

This thread is resolved. Here is a description of the problem and solution.

Problem: I have a page on my site that displays information about a User using Types and Views shortcodes. This works fine when I want to show information about the current User, but I cannot figure out how to show information about a different User.

Solution: Use a URL parameter to define the variable User ID used in the Driver Contract page. Build the markup for the administrator's link to the Driver Contract page with the proper URL parameter, based on the User in the list loop, something like this:

<wpv-loop>
...
<a href="http://yoursite.com/contract/?user_id=[wpv-user field='ID']">view</a>
...
</wpv-loop>

In the content of the contract page, you can access that user ID using the shortcode wpv-search-term:

[wpv-search-term param='user_id']

You can pass that value into your template's User shortcodes:

[types usermeta="contract-number" user_id="[wpv-search-term param='user_id']"][/types]

Relevant Documentation:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-search-term
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-user

This support ticket is created 6 years, 11 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.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Tagged: 

This topic contains 3 replies, has 2 voices.

Last updated by Tiit Sau 6 years, 11 months ago.

Assisted by: Christian Cox.

Author
Posts
#615882

I have users with custom role and some custom user meta fields.
User can sign up, see and edit own profile.
There are several views of users list for administrator.

Now i have to generate cotract per every user.
Any idea how to do it?

#616016
the list.png
contract page source.jpg
contract.png

Some explanation where i'm stopping.
The Contract right now is just a Page with some user meta shortcodes, where user id is defined and this page is linked from the list of users as regular page link.
To get valid links to dynamic contract in list of users for logged-in adminstrator, user id in shortcode have to be variable i guess. Just don't have a clue how to do it.

For logged in custom user just using user meta shortcodes with user_current='true' and all works fine.
The problem is for adminstrator to display any user contract with corresponding user data.

#616096

Hi, I'll be glad to assist. One option is to use a URL parameter to define the variable User ID used in the Driver Contract page. Build the markup for the administrator's link to the Driver Contract page with the proper URL parameter, based on the User in the list loop, something like this:

<wpv-loop>
...
<a href="<em><u>hidden link</u></em> field='ID']">view</a>
...
</wpv-loop>

In the content of the contract page, you can access that user ID using the shortcode wpv-search-term:

[wpv-search-term param='user_id']

You can pass that value into your template's User shortcodes:

[types usermeta="contract-number" user_id="[wpv-search-term param='user_id']"][/types]

More info about these shortcode here:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-search-term
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-user

#616127

Thank You Christian!

Everything works just fine now. You saved my day.

I like to work with Toolset.