This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Forum Replies Created

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • in reply to: Without UI settings, filter search results by custom fields #46180
    jlajla
    Participant

    Please 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;
    }

    `

    in reply to: CLI or API method for importing plugin configuration/settings #46162
    jlajla
    Participant

    You cannot access this content.

    in reply to: CLI or API method for importing plugin configuration/settings #46149
    jlajla
    Participant

    Thanks Ernest!

Viewing 3 posts - 1 through 3 (of 3 total)