Title: Multiple Filter Function
Last modified: December 23, 2016

---

# Multiple Filter Function

 *  Resolved [ldeschenes](https://wordpress.org/support/users/ldeschenes/)
 * (@ldeschenes)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/multiple-filter-function/)
 * I have a query coded like this:
    `query="select A, B, C, D, E, F where A='USER_APPARTEMENT'"`
 * and a Filter Funtion coded like this:
 *     ```
       function filter_gdoc_query ($query, $atts)
       {
       if ('https://docs.google.com/spreadsheets/--myfile1--/edit?usp=sharing' !== $atts['key']) { return $query; }
       $user_id = get_current_user_id();
       $key = 'appartement';
       $single = true;
       $appartement = get_user_meta( $user_id, $key, $single ); 
       return str_replace('USER_APPARTEMENT', $appartement, $query);
       }
       add_filter('gdoc_query', 'filter_gdoc_query', 10, 2);
       ```
   
 * That is working fine for –myfile1–.
 * Now I want to to the same for –myfile2-.
    Questions: 1. Should I code a new Filter
   Function ? 2. Should I modify the above Filter Function ? 3. In both cases what
   would be the proper code ?
 * Thanks in advance.
    -  This topic was modified 9 years, 5 months ago by [ldeschenes](https://wordpress.org/support/users/ldeschenes/).

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [Meitar](https://wordpress.org/support/users/meitar/)
 * (@meitar)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/multiple-filter-function/#post-8599238)
 * No one’s gonna write code foe you, but you’ve already got the right idea. You
   can do this either way, which way you choose is up to you.
 *  Thread Starter [ldeschenes](https://wordpress.org/support/users/ldeschenes/)
 * (@ldeschenes)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/multiple-filter-function/#post-8599943)
 * I had the time to do some testing and I finally one function did the job.
    THe
   final code is :
 *     ```
       function filter_gdoc_query ($query, $atts)
       {
       $user_id = get_current_user_id();
       $key = 'appartement';
       $single = true;
       $appartement = get_user_meta( $user_id, $key, $single ); 
       return str_replace('USER_APPARTEMENT', $appartement, $query);
       }
       add_filter('gdoc_query', 'filter_gdoc_query', 10, 2);
       ```
   
 * In fact, as it does not harm anything to parse every query, I just remove the
   part testing for the specific query :
    `if ('https://docs.google.com/spreadsheets/--
   myfile1--/edit?usp=sharing' !== $atts['key']) { return $query; }`
 * Thanks again for the great plugin!
    .

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Multiple Filter Function’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/inline-google-spreadsheet-viewer.
   svg)
 * [Inline Google Spreadsheet Viewer](https://wordpress.org/plugins/inline-google-spreadsheet-viewer/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/inline-google-spreadsheet-viewer/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/inline-google-spreadsheet-viewer/)
 * [Active Topics](https://wordpress.org/support/plugin/inline-google-spreadsheet-viewer/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/inline-google-spreadsheet-viewer/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/inline-google-spreadsheet-viewer/reviews/)

## Tags

 * [filter function](https://wordpress.org/support/topic-tag/filter-function/)

 * 2 replies
 * 2 participants
 * Last reply from: [ldeschenes](https://wordpress.org/support/users/ldeschenes/)
 * Last activity: [9 years, 5 months ago](https://wordpress.org/support/topic/multiple-filter-function/#post-8599943)
 * Status: resolved