Skip Navigation

[Closed] Pre-Filter drop down fields based on logged in user custom fields

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 1 reply, has 2 voices.

Last updated by Minesh 9 months, 4 weeks ago.

Assisted by: Minesh.

Author
Posts
#2691121
image.png

Tell us what you are trying to do?
I am trying to pre-filter the toolset blocks search filters based on the logged in users advanced custom fields associated with a user account. I am not sure where to start if perhaps using a toolset shortcut method would work or using something else like wpv_filter_query.
Are there any documentation or other user support requests related to this I could reference?

Rough example:

add_filter('wpv_filter_query', 'filter_toolset_denomination_dropdown_based_on_user_profile', #, #);
function filter_toolset_dropdown_based_on_user_profile_denomination($query_args, $view_settings, $example_view_id) {

if (is_user_logged_in()) {
// Get the current user
$current_user = wp_get_current_user();

$user_field_value = get_user_meta($current_user->ID, 'user_denomination', true);

// Not too sure what to do here
$query_args['meta_query'] = array(
array(
'key' => 'denomination',
'value' => $user_denomination,
//some action like : compare
)
);
}

return $query_args;
}

Is there any documentation that you are following?
https://toolset.com/documentation/customizing-sites-using-php/creating-templates-custom-post-type-archives/
https://toolset.com/forums/topic/how-to-use-wpv_filter_query/
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query

Is there a similar example that we can see?
Filters in question: hidden link

What is the link to your site?
hidden link

#2691384

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

We will require bit more information.

Do you mean that you have a user custom field "user_denomination" and you created the post type view using the blocks and based on the loggedin user's "user_denomination" custom field value you want to filter the custom post type posts.

If this is true I will require to check how exactly the value stored by "user_denomination" and with what postmeta key.

Please correct me if I'm wrong and send me problem URL where you are trying to display the view as well as 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.

The topic ‘[Closed] Pre-Filter drop down fields based on logged in user custom fields’ is closed to new replies.