Is there a way to let admins download the event list csv from the front end?
Is that possible?

Aaron Robb
Yes you could, edit the event page to include a link:
$url = add_query_arg(
array(
'eo-action' => 'export-bookings',
'event_id' => get_the_ID(),
),
admin_url( 'admin-post.php' )
);
printf( '<a href="%s">Download bookings</a>', $url );

Stephen Harris
Using that code gives a blank page so far…what would the full url be normally for downloading?
This function gives this url:
mywebsite.com/wp-admin/admin-post.php?eo-action=export-bookings&event_id=234
This is the link I think it should be, but not sure how to generate it:
mywebsite.com/wp-admin/edit.php?post_type=event&page=bookings&event_id=234&eo-action=export-bookings
Does it make sense to use that?

Aaron Robb
If you type that url in the address bar then it will take you to a white page, but it’ll trigger the download of the CSV file. If you click the link, it’ll just download the CSV file.
But you can replace
admin_url( 'admin-post.php' )
with
admin_url( 'edit.php?post_type=event&page=bookings' )
if you prefer.

Stephen Harris
Great, that works, thanks!

Aaron Robb
Stephen,
I’ve found an issue with our solution here that maybe you can help me with.
This works great for admins, but I have another user level, “Event Creator”, that I want to allow to download bookings this way. Problem is when they click the link, it goes to their profile page instead of downloading. I’m assuming its a permission thing, but I have all ‘event’ related permissions checked off for them (using a role editor).
Is there another thing we need to give them permission for to download bookings?

Aaron Robb
Hi Aaron,
Generally they would need to be able to manage bookings for the event – you can select the user’s Privleges in Settings > Event Organiser > Permissions.

Stephen Harris
ok, those permissions were set up already. It must be something stopping that level of user from accessing the “admin-post.php” area. There are other permission/rules i have set up, so it must be that. Just eliminating possible factors.
Thanks for the help!

Aaron Robb