Title: Filter with link &#8211; URL Variables using array_filter
Last modified: October 23, 2018

---

# Filter with link – URL Variables using array_filter

 *  Resolved [wordpressorgpublic](https://wordpress.org/support/users/wordpressorgpublic/)
 * (@wordpressorgpublic)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/filter-with-link-url-variables-using-array_filter/)
 * Hi.
    I was wondering if you would be so kind to give an example (similar to the
   from_date [https://wordpress.org/support/topic/url-variables/#post-10684492](https://wordpress.org/support/topic/url-variables/#post-10684492))
   just using a GF field value. Creating a link to download only the rows where 
   GF1 filed 33 value number = current post ID.
 * Thank you.
 * <?php
    // functions.php
 * /**
    * Filtering rows example ?workshop_id={workshop} * Include row by default,
   but exclude based on a certain condition * In this case we exclude every row 
   where $workshop value does not equal current post ID * And we take $workshop 
   value from the GF 1 filed 33 */
 * add_filter(‘gfexcel_output_rows’, function ($rows) {
    if (!array_key_exists(‘
   workshop_id’, $_GET)) { return $rows; // nothing to filter }
 *  $workshop_id =
 * ??????????
 *  return $rows; //include this row by default
    }); });

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

 *  Plugin Author [Doeke Norg](https://wordpress.org/support/users/doekenorg/)
 * (@doekenorg)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/filter-with-link-url-variables-using-array_filter/#post-10807238)
 * hi [@wordpressorgpublic](https://wordpress.org/support/users/wordpressorgpublic/),
 * Sure I’d love to help. But in order for this to work, you need to have a field
   in your form that contains the workshop_id. Can you provide the ID of that field?
 * I’ll try to find some time later in the day to provide the example.
 *  Plugin Author [Doeke Norg](https://wordpress.org/support/users/doekenorg/)
 * (@doekenorg)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/filter-with-link-url-variables-using-array_filter/#post-10808605)
 * Hi [@wordpressorgpublic](https://wordpress.org/support/users/wordpressorgpublic/),
 * I have small example, but I found it’s not really user-friendly. So I added an
   enhancement on the roadmap to add more info the value object, so we can know 
   more easily what column we filter against. And maybe, I’ll try and add some easier
   filter-function in the future. But I need to make that a less abstract idea 🙂
 * For now you’ll have to use something like this:
 *     ```
       add_filter('gfexcel_output_rows', function ($rows) {
           if (!array_key_exists('workshop_id', $_GET)) {
               return $rows; // nothing to filter
           }
   
           return array_filter($rows, function ($row) {
               // $row is an array with every column, starting at 0. So if you know column 4 has the ID, you use $row[3].
               // Just count the columns and subtract 1. This example is assuming column 4 has the info.
               // 'strval' is needed (for now) because the value of the row is most likely a value object, and not a string.
               return strval($row[3]) === strval($_GET['workshop_id']);
           });
       });
       ```
   
 * I hope this helps you out.
    -  This reply was modified 7 years, 7 months ago by [Doeke Norg](https://wordpress.org/support/users/doekenorg/).
      Reason: Smaller example
 *  Thread Starter [wordpressorgpublic](https://wordpress.org/support/users/wordpressorgpublic/)
 * (@wordpressorgpublic)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/filter-with-link-url-variables-using-array_filter/#post-10809427)
 * Hi Doeke, it WORKS 🙂
    wow, I am so appreciative, and impressed. Not just with
   the great plugin you created, but the incredible support and willingness to help.
   Thank you again.

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

The topic ‘Filter with link – URL Variables using array_filter’ is closed to new
replies.

 * ![](https://ps.w.org/gf-entries-in-excel/assets/icon.svg?rev=3434379)
 * [GravityExport Lite for Gravity Forms](https://wordpress.org/plugins/gf-entries-in-excel/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/gf-entries-in-excel/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/gf-entries-in-excel/)
 * [Active Topics](https://wordpress.org/support/plugin/gf-entries-in-excel/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/gf-entries-in-excel/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/gf-entries-in-excel/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [wordpressorgpublic](https://wordpress.org/support/users/wordpressorgpublic/)
 * Last activity: [7 years, 7 months ago](https://wordpress.org/support/topic/filter-with-link-url-variables-using-array_filter/#post-10809427)
 * Status: resolved