The Community forums are being phased out in favor of a new Slack group.
Add your email address below to get an invitation to join the community slack group

Slack Signup
Newsletter Optin
Help Desk

Exporting a CSV of entries by a user

Labels

This Discussion is public

Notifications

I've managed to create a simple link which will allow a logged-in user to download their own entries of a form in a csv format.

./wp-admin/admin-ajax.php ?frm_action=0 &action=frm_entries_csv &form=X &s=[user_id] &fid=user_id

(X being the ID of the form. I've also had to strip the link code from the above example and add spaces as this site thinks it's spam!)

This works really well, but it generates a CSV with columns for every field in the form - and I'd really like to be able to filter out some of the fields which include such things as -  ip/user_id/timestamp/key and a few of my own created fields which don't need to be in the user exported CSV etc...

I've tried adding: add_filter('field_id=86,70,76,77,87,83’) - but that doesn't do anything...

Can anyone assist?

Anyone?

Hi Sam,
I didn't try this but you should be able to use this hook to filter out columns

https://formidableforms.com/knowledgebase/frm_csv_columns/

Hi,

Yes, I've looked over this, but how do I use this code within a hyperlink?

You can add the PHP code for the hook inside your Wordpress theme functions.php or use code snippet plugin (my personal preference)

https://es.wordpress.org/plugins/code-snippets/

Thanks sujee,

I'd forgotten about CODE SNIPPETS (even though my site is using this plugin)...!

I managed to use the code:

add_filter( 'frm_csv_columns', 'remove_id_column', 10, 2 ); function remove_id_column( $headings, $form_id ) { if ( $form_id == 5 ) { //change 5 to your Form ID unset( $headings['created_at'] ); unset( $headings['updated_at'] ); unset( $headings['user_id'] ); unset( $headings['updated_by'] ); unset( $headings['is_draft'] ); unset( $headings['ip'] ); unset( $headings['id'] ); //change id to the header of the column to be removed unset( $headings['item_key'] ); } return $headings; }

for 1 of my 3 forms - but my site crashed when trying to use the same snippet three times for 3 forms (with the ( $form_id == 5 ) changed to match my form's ID's.

Can you suggest a work around?

I tried ( $form_id == 5,14,21 ) but that didn't work....

The correct way of checking whether the array has a value is


if (in_array($form_id, array(5,14,21))) {
.....
}

By the way, when you copied the snippet individually for each form, it most likely crashed because all three functions had the same name "remove_id_column". If you renamed them differently, it would not have crashed. Anyway, array approach is more efficient than duplicating.

That worked a treat mate!

Many thanks for your help and assistance.

 

Discussion closed.