Skip Navigation

[Resolved] When I place a Custom Search Filter I cannot select USER.

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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 17 replies, has 2 voices.

Last updated by Minesh 1 year, 4 months ago.

Assisted by: Minesh.

Author
Posts
#2624549
Schermafbeelding 2023-07-17 om 10.30.59.png

Tell us what you are trying to do?
I have everything almost working fine, only I can't search by user yet.
When I place a Custom Search Filter I cannot select USER.
See screenshot.
What am I doing wrong?

What is the link to your site?
hidden link

#2624569

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Because you can not build a custom search form user. You can add frontend filter to post type view or archive for custom fields/taxonomies but not for the user.

Do you mean you want to add frontend filter so that user can filter the posts based on the selected user? If so you can not add frontend filter for user but if you want to just pre-filter the posts based on the post author then its possible.

Here is the doc that might help you to understand the limitation and workaround you have to follow to build custom search for users:
- https://toolset.com/course-lesson/how-to-create-custom-searches-and-relationships-for-users/

#2624627

Thanks for your quick response.
I have already built a view where the USER can see and edit his own posts. This is visible when this USER is logged in.

I also built a view where all messages from all USERS are visible, these are visible to all visitors to the site.

Is it possible that a visitor to the site can search for messages posted by 1 specific USER?

#2624641

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

No - its not possible to add a frontend filter by user field or user custom field.

But if you able to store the ID of the user to a custom field then we can make it happen but to ensure the what could be the best possible workaround I will require to review your current setup.

Can you please share on what page you want to add the frontend filter to what view and send me admin access details.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2624721

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Is it possible that a visitor to the site can search for messages posted by 1 specific USER?
==>
It is not possible to offer frontend filter for user but what you can do is add a custom field that should hold the value of username and then add this custom field as frontend filter. Will that work for you?

If yes, then you can create a custom field and make sure that when the message/post is created you should save the username as the custom field value and then add this custom field to your view as frontend filter.

#2624727

I think that works for me.
I assume that with CustomField I have to create a field where the name of the user is automatically included?
So that it can be searched for via the FrontEnd.

But how do I create that field?

#2624729

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

You have to add that field to your custom field group that holds other fields and you have to make sure that when you create/submit new entry that field should be automatically loaded with the username of the user.

You can go to: Toolset => Custom Fields and to your desired custom field group add the custom field.

Now, I would like to know from where you are added the new entries. Is it added from frontend or backend?

#2624733
Schermafbeelding 2023-07-17 om 15.08.58.png

Yes I know, but how do I create that field?

#2624745

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

You can add the field name and slug as per your choice and create that field.

The field value needs to be populated when you save/create new post. That is why I asked you in my previous reply that from where you are creating the posts, from frontend or from backend?

#2624749

O Sorry, The post are created from the frontend.

This is the form.
hidden link

#2624915

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Ok - so when the above form will be submitted, we can use the following hook "cred_save_data" to populate the current user name.

More info:
- https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data

So when user will submit the above form - we will automatically capture the user name and store it to the newly created custom field that will hold the username value. Does that makes sense?

Can you please tell me now if you already created the custom field that will hold the username value?

#2625343
Schermafbeelding 2023-07-19 om 16.06.13.png

The name of the field is: schoolnaam

#2625579

Can you help me with this?

#2625581

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Sure. Can you please tell me if you have created the form and added to the Designer single post?

#2625607

Yes, I created the field (school name). Added to the form.
This is now online (test mode)

hidden link

and

hidden link