Forum Replies Created
-
AuthorPosts
-
November 25, 2023 at 1:32 am in reply to: Without UI settings, filter search results by custom fields #46180
jla
ParticipantPlease disregard!
I found the answer in the documentation itself, apologies.
The solution was to write a plugin, as below, corresponding to my above use case:
`
add_filter(“asp_query_args”, “filter_search_by_user_uuid”, 10, 2);function filter_search_by_user_uuid($args, $search_id) {
// Replace ‘2’ with the ID of your specific search bar
$target_search_id = 2;if ($search_id != $target_search_id) {
// If this isn’t the target search bar, don’t modify the query
return $args;
}// Get the current user ID and retrieve their UUID
$current_user_id = get_current_user_id();
$user_uuid = get_user_meta($current_user_id, ‘user-uuid’, true);// Check if user UUID is available
if ($user_uuid) {
// Add a post meta filter to the query arguments
$args[‘post_meta_filter’] = array(
array(
‘key’ => ‘user-uuid’,
‘value’ => $user_uuid,
‘operator’ => ‘=’,
‘allow_missing’ => false
)
);
}return $args;
}`November 24, 2023 at 9:30 am in reply to: CLI or API method for importing plugin configuration/settings #46162jla
ParticipantYou cannot access this content.
November 23, 2023 at 9:38 pm in reply to: CLI or API method for importing plugin configuration/settings #46149jla
ParticipantThanks Ernest!
-
AuthorPosts