Problem: I would like to get the value of a custom User field in PHP, and use that value in the Query Filter shortcode arguments of a View. Then I would like to use the results of that View in the shortcode arguments of another View. I'm using types_render_usermeta and render_view, but the results are not what I expect.
Solution: The APIs types_render_usermeta and render_view are designed to output content, and can include extra markup and syntax that will not work correctly in filters. Instead of using types_render_usermeta to get the value of a custom field, use the WordPress API get_user_meta, since it will return the raw value without any extra markup. Instead of relying on the results of render_view as an argument, access the data more directly using get_view_query_results.
Relevant Documentation:
https://codex.wordpress.org/Function_Reference/get_user_meta
https://toolset.com/documentation/programmer-reference/views-api/#render_view
https://toolset.com/documentation/programmer-reference/views-api/#get_view_query_results
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)
This topic contains 2 replies, has 2 voices.
Last updated by 6 years, 7 months ago.
Assisted by: Christian Cox.