Filtering CSV Downloads By Fo

By: Lee Mansfield | Asked: 12/15/2023
ForumsCategory: Code HelpFiltering CSV Downloads By Fo
Lee Mansfield asked 7 months ago
Hi, so I've got a form and view showing results on a page. There is a range of fields to filter results by and this works fine and shows the filtered results etc I end up with a query string something like:- domain.com/my-page?ca=Analytics&st=3 I'm using the hook 'frm_csv_where' to try and and match the filtered results on screen but I can only seem to get the 'created_at' field to work and do anything of note. What I would like to do is to somehow match the filters applied in the query string.
Start your code here
function customize_csv_export_where($where, $args) {
$category=isset( $_GET['ca'] )?sanitize_text_field( $_GET['ca'] ):'';
$status=isset( $_GET['st'] )?absint( $_GET['st'] ):0;

$where['created_at >'] = '2023-10-01 00:00:00';
return $where;
}
add_filter( 'frm_csv_where', 'customize_csv_export_where', 10, 2 );
As I say the code snippet above only works on the date field but would love to know how I can get it to pick up the field values set in the query string.   Thanks
1 Answers
Rob LeVineRob LeVine answered 7 months ago
In your code, you're not actually using $category or $status after setting them. You'll need to do something similar to this example on the frm_csv_where page to find entries that match the metadata you're filtering on.
Lee Mansfield replied 7 months ago

Thanks for that Rob, I will check it out and attempt to understand it 🙂

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right