Skip Navigation

[Resolved] In a parametric search I want to be able to search on related user

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

Problem:
The issue here is that the user wanted to filter his parametric search view by his users i.e authors.

Solution:

The solution is that you will need 2 views and a custom filter on your view.

First you will need to create a view that will list the Authors ID.

Example of the author ID view

[wpv-items-found]
	<!-- wpv-loop-start -->
		<wpv-loop>[wpv-item index=1][wpv-user field="ID"][wpv-item index=other],[wpv-user field="ID"]</wpv-loop>
	<!-- wpv-loop-end -->
	[/wpv-items-found]

On an important note that for the Author ID view you will need to use some javascript to strip the white spaces from the view. So add this to the JS section.

jQuery("#wpv_control_select_post_author > option").each(function () {
        this.value = this.value.trim();

	});

Then you will need the Author Name view.

[wpv-items-found]
	<!-- wpv-loop-start -->
		<wpv-loop>[wpv-item index=1][wpv-user field="nickname"][wpv-item index=other],[wpv-user field="nickname"]</wpv-loop>
	<!-- wpv-loop-end -->
	[/wpv-items-found]

Finally on our view with the parametric search view you will create a custom filter like this.

<label>[wpml-string context="wpv-views"]Post Author[/wpml-string]</label>
	[wpv-control-postmeta field="post_author" type="select" source="custom" url_param="author-filter" values="[wpv-view name='list-author-id']" display_values="[wpv-view name='list-author-name']"]

Then under the query filter you will click "Add A filter" and then add the filter for author and set it to be filtered by a URL parameter

This support ticket is created 7 years 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 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 10 replies, has 2 voices.

Last updated by JosV9233 7 years ago.

Assisted by: Shane.

Author
Posts
#598622

There is this custom post type that is related to the author (user). When I do a parametric search I would like to be able to get all results for one specific user.

Is there any documentation that you are following? I have not found documentation on this. I thought about this because the order form that fills the order database has the user field (see hidden link).

When I want to search in that database I want to be able to select a specific user. The form under construction is here: hidden link

#598682

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hello,

Thanks for creating a new ticket on this.

So to get this accurately you want to filter a list of posts by a dropdown list of artists correct?

Please let me know

Thanks,
Shane

#598700

Hi Shane,

It's kind of the same issue as the former issue I needed help about. It is a list of orders connected to the users. In the parametric search I want a user field that, if chosen and used, would produce a list of orders of that user. In that search I want to filter on dates and all kind of stuff, but that it easy, that is all in the same custom post type. The user, taken from the user database worries me.

Jos

#598979

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Jos,

After a few minutes I was able to develop a solution and it required 2 additional views and some custom jquery to achieve.

The views are List Author Name and List Author ID

These populate a dropdown list in your filter in order for the items to be filtered by the author.

Please let me know if this helps.
Thanks,
Shane

#599056

Shane, that's great. It looks like (I haven't looked in the back-end yet) you solved it!!

Very well done, thank you very much.

Best regards,

Jos

#599090

Shane, could you give a short explanation how this works with the two views. I have been looking at it and do not fully grasp it.

Thanks.

#599205
Toolset2.jpg
toolset1.jpg

Hello Shane,
Another question, well actually two. How do I achieve what I show in the attached images?

Picture one (toolset1.jpg): replacing text.
Picture two (toolset2.jpg): starting with a neutral choice (like in toolset1.jpg) and inserting text there.

I have been looking through it for a while and inserted "select_text='klik hier om te kiezen'" in various places without succes.
Hope you can give me a hint.

Regards,
Jos

#599219

I want to add:

In toolset2.jpg it is essential to be able NOT to select the post author. Otherwise you cannot search on dates for everyone.

#599290

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Jos,

Sorry for the delay in response.

I'm currently having a look at this for you.

Thanks,
Shane

#599293

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Jos,

All that was needed was to add the default value manually in the view filter here

[wpv-control-postmeta field="post_author" type="select" source="custom" url_param="author-filter" values="0,[wpv-view name='list-author-id']" display_values="--not set---,[wpv-view name='list-author-name']"]

So you can see that i've add --not set-- to the display values and also 0 for the value of the default item.

Thanks,
Shane

#599383

Shane, between your two last messages were literally 7 minutes!

Thanks a lot again.
Jos