1

I need to set up a semi-regular export of people who have signed up on our website. We're using Drupal 7. I can do a simple export of the Users table, but that doesn't include the additional custom fields we've added.

Is there a module already available in D7 that handles exporting the user database with the custom fields associated with these records?

If not, is there a simple query I can do to identify the custom fields associated with the registration process at runtime? I'd like the export to still work if my customer decides to add a new field.

  • How were these custom fields added? I've found the Profile CSV module helpful, though I'm not sure about a D7 status it could be a useful starting point. – akalata Aug 16 '11 at 2:09
1

I can't think of any contrib module that would do this, but I can think of a somewhat simple custom module solution.

Create a custom module that has a hook_menu call back to a form that you've built with the form api that has a submit button that says "Generate Report".

Make sure to create a corresponding permission with hook_permission so only users of your choice can access this form.

Then in the submit just run a query ( using db_query ) on the users table to get all uid's, then iterate thru each uid to load the full user with user_load and build a CSV row with the fields you want, or all fields. After building the entire csv save it somewhere on the server with a timestamp and link the user to it, or just stream it back to them as a download.

4

I know that this question has already been answered, but thought I'd point out the Views Data Export module for anyone looking for a contributed solution rather than a bespoke one. This module allows you to define Views that generate CSV files for export. We're using this with Drupal 7 for a client so that they can export all users and their associated custom fields. It's working well.

  • 1
    Views Data Export module has some performance issues because of the way Views handles user entities. If you need anything that scales, this is probably not the way to go. – laura Jan 30 '13 at 16:26
  • There is the batched export option which should resolve this issue. Check it inside the "views data export" display options. – Druvision Apr 3 '14 at 10:18
0

Another option to consider for addressing these requirements is the Forena module.

You would use its report writing features (such as its WYSIWYG report writer and/or it's query builder) to first create a report that fits your needs. The result of it could be a tabular output and/or graph. After the report content matches the specifications, you could save it as (e.g.) a CSV file, or XLS, or DOC, or ...

Here is a quote from one of the forena community docu pages, i.e. Reasons for considering Forena:

Reports created by Forena (combined with SVGGraph and mPDF) can be saved (exported) as PDF documents with embedded graphs. Other supported formats for saving a report are CSV, XLS, DOC, HTML, etc.

The Forena Video demos and tutorials contain quite some links to live demos.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.