Skip Navigation

[Resolved] Searchable View showing user fields of post author

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

Problem:

- A custom post type "Members", each "Member" post author is different WordPress user

- A post view, query "Member" posts,

Going to filter the result by custom user fields.

Solution:

It is not possible within Toolset Views/Blocks plugin, since Toolset Views/Blocks plugin is using WordPress class WP_Query to query posts, see WP document:

https://developer.wordpress.org/reference/classes/wp_query/

There isn't such kind of option to filter result by user fields.

I suggest you try to move the custom user fields as custom post fields of post type "Members".

Relevant Documentation:

This support ticket is created 4 years, 7 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
- 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 3 replies, has 2 voices.

Last updated by JamesS2731 4 years, 7 months ago.

Assisted by: Luo Yang.

Author
Posts
#1623453

Tell us what you are trying to do? I'm trying to show a list of all members that can then be searched by the various fields displayed.

I created the CPT 'Members' as a way to manipulate the user data, and automatically created a Member post when a user was created (the user being the author of the post).

Almost all fields are custom user fields, and I can access these on the Loop editor, but I cant access them when creating a custom search filter.

For example, one of the custom user fields is 'home phone' (wpcf-home-phone). I would like a text search box at the top of the view where a user can input a phone number (or part of one).

I can add the field wpcf-home-phone to the loop but it doesn't show in the custom search filter available fields. If I swap post view for user view, I can still see the field, but then cant add a custom search.

Is there any documentation that you are following? Many previous support questions but none that Iv'e found the answer.

Is there a similar example that we can see? Here's a similar view I created for Members Cars which was simpler as I didnt require any user fields to be involved - hidden link - You'll be able to see the various search filters.

What is the link to your site? hidden link

Apologies in advance as I've asked you quite a few questions recently but this one really has me stumped.

Kind regards
James

#1623991

Dear James,

I assume we are talking about this case:
- A custom post type "Members", each "Member" post author is different WordPress user
- A post view, query "Member" posts, you are going to filter the result by custom user fields.

If it is, it is not possible within Toolset Views/Blocks plugin, since Toolset Views/Blocks plugin is using WordPress class WP_Query to query posts, see WP document:
https://developer.wordpress.org/reference/classes/wp_query/
There isn't such kind of option to filter result by user fields.

I suggest you try to move the custom user fields as custom post fields of post type "Members".

#1624183

Hi Lou,

Many thanks for your quick response.

Ok, I'm happy to do that. If I create matching fields in the Member post type, whats the best way of moving all date over? Export and reimport? or is there a more simple method?

Kind regards
James

#1624849

Many thanks Luo, I've reimported the data to fields in the Members post type now. Issue resolved.

Kind regards
James