Skip Navigation

[Resolved] Using Types Field with a view to get the ID of the post

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

Our next available supporter will start replying to tickets in about 0.68 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 2 replies, has 2 voices.

Last updated by stuart 3 years, 9 months ago.

Assisted by: Luo Yang.

Author
Posts
#1962287

I am trying to use a View to get an ID that I use in the item= element of a Types field - like below:

This works as expected:
[types field='first-name' item='503'][/types]

This doesnt.
[types field='first-name' item='[wpv-view name="member-profile-id"]'][/types]

The view work on its own an outputs the correct ID number.
[wpv-view name="member-profile-id"]

Combining them together doesn't output anything.

Results:
ID number: [types field='first-name' item='506'][/types]
<br>
Types with view: [types field='first-name' item='[wpv-view name="member-profile-id"]'][/types]
<br>
Member profile ID: [wpv-view name="member-profile-id"]

----
ID number: Stuart
view:
Member profile ID: 506

What I am trying to do is prefill a CRED form with a custom post profile person name (not a user name) when they submit the form.

The 'member' has a 'profile', and on the profile, there are a number of custom fields that I need to pull, e.g fist name, last name.
However, I need to get the ID of the individual's profile first to be able to reference the field to get the data.

I am sure there is something obvious that's stopping it ...

help 🙂

Cheers

#1962389

Hello,

The "item" attribute does not support [wpv-view] shortcode:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/item-attribute/

Since [wpv-view] shortcode will output extra HTML tags in the result, so you can not use it as "item" attribute, I suggest you display the custom field value in post view "member-profile-id" directly.

#1962407

Hmm, that's a shame as it would be quite useful.

My workaround ( for my reference and anyone else), while a view shortcode doesn't work in the 'item' attribute what I can do instead is use a types usermeta shortcode in the item attribute - which does work.

[types field='first-name' item="[types usermeta='activated' current_user='true'][/types]"][/types]

When I first create the member profile I will store this reference ID on the user meta and I can then easily reference it.

This should work ok.

There is always a workaround!

cheers!