Skip Navigation

[Resolved] [types usermeta="myfieldname" user_current="true"][/types] fails to display

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.

This topic contains 6 replies, has 3 voices.

Last updated by Brad 5 years, 5 months ago.

Assigned support staff: Luo Yang.

Author
Posts
#289409

I use the shortcode below and expect to see the value of the user meta field "omw_zoom" but instead I see null.

[types usermeta="omw_zoom" user_current="true"][/types]

The user meta field exists and has a value. I can see the field in Types user fields control and in phpMyAdmin.

In the example screenshot of shortcodes used on the page in question, all of the Types shortcodes return empty. The wpv-current-user shortcode returns correctly the current user login info.

Why do the Types shortcodes not return the expected values and how can I display those values with Types shortcodes?

#289711

The first thing that catches my attention is that these fields are not under Types Control.

How did you create these fields and is it possible to add them to Types control?

#289748

Hi Caridad,

The fields were created by one of my plugins using update_user_meta(). I wrote a small shortcode to read them using get_user_meta(). It works as I had hoped the Types shortcode would. So, I have resolved my issue but still would like to find out how I might have used the Types shortcode successfully to get a user meta field value.

I thought that Types would be able to display both fields under Types control and fields not under Types control. I don't wish to add my new user meta fields to Types control. I have had better luck with Types on post meta than on user meta.

I thought perhaps my new user meta fields might have slipped under Types' view because I created them with update_user_meta() rather than add_user_meta(), but reconsidered that thought when I saw all of my new user meta fields listed correctly in the Types user fields control. It seems odd that Types can see the fields there but cannot successfully return the values in the Types shortcode.

I'm sure you are busy with many unresolved issues, so feel free to mark this issue resolved and move on to help other people. I do think there is an issue in Types that needs to be resolved here, however. I'll leave this issue status as "I still need assistance" rather than "My issue is resolved" in case you need any further information.

#290804

The types shortcodes can only be used with fields controlled by types.

There are specific Views shortcodes will work with any type of custom field:

1) wpv-post-field can be used to display postmeta from outside of Types:
https://toolset.com/documentation/views-shortcodes/#wpv-post-field

2) wpv-user can be used to display usermeta from outside of Types:
https://toolset.com/documentation/views-shortcodes/#wpv-user

#290866

Thanks for clarifying that the Types shortcodes can only be used with fields controlled by Types.

I tried the Views shortcode without success. I see in the documentation that you linked that the Views shortcodes context is "inside a user view loop." Does that mean I cannot use the Views shortcodes directly on a page but only in a View or Content Template on the page?

#291683

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

Are you going to display custom fields of current login user?
Please try views shortcodes like this:
[wpv-user field="omw_zoom" id='[wpv-current-user info="id"]']

More help:
https://toolset.com/documentation/views-shortcodes/#wpv-user
https://toolset.com/documentation/views-shortcodes/#wpv-current-user

#292577

Thank you, Luo. That combination of shortcodes worked.