Support Forums

Looking for support? You can access the support system via your account.

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

Viewing 3 posts - 1 through 3 (of 3 total)
  • Jonathan Whitney
    #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?

    Jonathan Whitney
    #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 Moderator
    #260234

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

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

The topic ‘ACF, Post Meta, Relevanssi conflict’ is closed to new replies.