ACF, Post Meta, Relevanssi conflict

Forums › Forums › Search & Filter Pro › ACF, Post Meta, Relevanssi conflict

Viewing 3 posts – 1 through 3 (of 3 total)
  • Anonymous
    #260217

    Hi, I am currently using Advance Custom Fields and Relevanssi to search my custom post type. Before implementing Relevanssi I was using sf_edit_query_args to edit the $query_args to filter by the current logged in user based on meta data.

    Since adding Relevanssi the filter sf_edit_query_args no longer works. I receive 0 results whenever attempting to search. I also attempted to edit the “Post Meta” tab on a form and that yields the same results.

    Is there any way to use Relevanssi and still filter based on post meta data?

    Anonymous
    #260220

    I was able to fix my issue. Here is my code snippet in case anyone runs into the same issue…

    function set_user_di( $query_args, $sfid ) {
      //if search form ID = 225, the do something with this query
      $nam_options = get_option( 'nam_options' );
      $inventory_form_id = (int)$nam_options['my_inventory_form_id_number'];
    
    	if ( is_user_logged_in() && $sfid==$inventory_form_id ) {
        if ($query_args['meta_query']) {
          array_push($query_args['meta_query'], array(
            'key' 		=> 'owner',
            'value'		=> get_current_user_id(),
            'compare' 	=> '=',
          ));
        } else {
          $meta_query = array(
            array(
              'key' 		=> 'owner',
              'value'		=> get_current_user_id(),
              'compare' 	=> '=',
            ),
          );
    
          $query_args = $meta_query;
        }
      }
    
    	return $query_args;
    }
    add_filter( 'sf_edit_query_args', 'set_user_di', 20, 2 );
    Trevor
    #260234

    Thanks for sharing. I will close this thread for now.

Viewing 3 posts – 1 through 3 (of 3 total)
Search & Filter Support
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

We also use cookies to store items in your cart as well as allowing your to login on the site.

You can adjust all of your cookie settings by navigating the tabs on the left hand side.

By continuing to use this site, you also agree to our Privacy Policy.