Sauter la navigation

[Résolu] How to search user by age using a shortcode value?

This support ticket is created Il y a 5 années et 10 mois. 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)

Ce sujet contient 5 réponses, a 2 voix.

Dernière mise à jour par Luo Yang Il y a 5 années et 10 mois.

Assisté par: Luo Yang.

Auteur
Publications
#1220986

Tell us what you are trying to do? I'm creating a custom search where I want to use a between filter using an age shortcode that generates its value by a date custom field.
And also I want to display the between filter using something like this lien caché

Is there any documentation that you are following? I'm searching for it, but I don't have found anything.

Is there a similar example that we can see? Something like this lien caché, but for the age.

What is the link to your site? lien caché

#1221349

Hello,

There isn't such a built-in feature within Toolset Views plugin, it needs custom codes, but according to our support policy, we don't provide custom codes support:
https://toolset.com/toolset-support-policy/

You can check it with our Toolset Contractors:
https://toolset.com/contractors/

You can also add a feature request for it:
https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/

Here are my suggestions:
1) You can use the custom CSS/JS/HTML code to setup the age range filter in front-end search form according to the demo you mentioned above:
https://toolset.com/forums/topic/how-to-search-user-by-age-using-a-shortcode-value/#post-1220986

2) When user change the value of age range filter, use JS codes to change values of two hidden fields:
a) age-from
b) age-to
lien caché
Then user submit the search form, it will pass above URL parameters to view

3) Use filter hook wpv_filter_query to trigger a custom PHP function, in this function, do these:
- Get the URL parameter's values
a) age-from
b) age-to
- use those value to apply your custom filter to Views query

Notice:
If the "date custom field" is created with Types plugin, then database, the custom date field value is in timestamp format.

More help:
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query
https://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters
lien caché

#1221551

Hi Lou,
thanks for your reply.

So, if I do only a simple custom search by age, without using extra js code, selecting the age range using two text box or two select box, where the user can set the range of ages, do I need to follow the point 3?

#1221570

Yes, the step 3) is required, since you are passing age values using two text box or two select box, for example
age-from: 10
age-to:

You still need to turn them into timestamp values, then apply them to Views query.

#1224049

Thanks for your help, but I don't know what I should do exactly...

I have searched for a guide to do what I need, but I have found only these:
https://toolset.com/forums/topic/searching-by-age-range-with-multiple-values/
and
https://toolset.com/de/forums/topic/issue-with-filtering-by-date-custom-field/

And they do only the search about a pre-setted range...

Can you help me sending me a step by step guide?
Can I use the Toolset Custom Code Section?

Thanks

#1224280

Q1) Can you help me sending me a step by step guide?
As I mentioned above:
according to our support policy, we don't provide custom codes support, you can check it with our Toolset Contractors:
https://toolset.com/contractors/

Q2) Can I use the Toolset Custom Code Section?
Yes, you can use the Toolset Custom Code Section, here is a document about "Adding custom code to your WordPress site"
https://toolset.com/documentation/adding-custom-code/

For your reference.