I need to export a list of site users to a csv/xlsx file. I am creating an admin page with a download button which should run the export function.
I need to export the following data from wp_users:
I need to export the following data from wp_usermeta:
- institution (this is a custom meta field)
How can I go about exporting this on the click of a button? I have the admin page and button setup but not sure on the correct query to get the data and put it into a csv