3

I want to export users list with all custom fields. I have tried the Users Export module but its export only below fields:

  • uid
  • mail
  • name
  • created
  • access
  • login

Is there any solution to solve this problem?

1

3 Answers 3

2

You can use the Drush Entity module:

With drush entity you can query the entity system available for Drupal 8, 7 and (some of) 6.

Getting all users with some fields:

drush entity-read user `drush entity-read user` --fields=uid,mail,name,created,access,login

Getting one user with all the fields:

drush entity-read user 1 --fields=* --format=json

Getting all the users with all the fields:

drush entity-read user `drush entity-read user` --fields=*

Getting some users with some fields:

drush entity-read user 1 2 --fields=uid,mail,name,created,access,login --format=export

Output (for the last command):

 1  [email protected]  admin  1353518169  1470089957  1469713365
 2  [email protected]  webadmin  1353518169  1470089957  1469713365

If you want to try with another options you can read this page: http://build2be.com/content/drush-entity-support-patch-needs-review

3
  • So what is it that you do not use Drush for these days? Aug 5, 2016 at 11:14
  • 1
    @Pierre.Vriens I'm studying Drush in these days, I think is very powerful for make scripts to process a lot of data and for get quickly information of your site. Aug 5, 2016 at 13:13
  • 1
    Drush is indeed amazing! And it'll be interesting to see how it is going evolve as compared to the "Console" in D8 ... Aug 5, 2016 at 13:21
1

There are many option to achieve this.

You can create a user view and use Views data export module for export.

Another option to achieve this is Data export import module.

7
  • Data export import module export the user but still custom field are not showing. I also want the user export in csv file. Any idea?
    – reshu
    Aug 2, 2016 at 5:37
  • How you create the custom fields?
    – DRUPWAY
    Aug 2, 2016 at 5:41
  • Yes you can export user list in csv file using "Views data export" module.
    – DRUPWAY
    Aug 2, 2016 at 5:42
  • Thank you. Now I am able to export data in csv file with Views data export module. There is an option for Batched export which helps to export data in small segments but it is not working.
    – reshu
    Aug 2, 2016 at 9:02
  • Also I want to add the checkbox in user list to export the selected users. Any idea?
    – reshu
    Aug 2, 2016 at 9:03
1

Start from a Forena's sample report (Active users)

Install the Forena module (disclosure: I'm a co-maintainer of it) and start from the "Active Users" report (part of Drupal Administration report category) which is delivered with it. Here is a sample output of it:

+-----------+-----------------------+-------------------------+---------+
| User      | Email                 | Last Logged in          | Actions |
+-----------+-----------------------+-------------------------+---------+
| Webmaster | [email protected] | Sun, 03/27/2016 - 18:39 | logs    |
| Admin     | [email protected]      | Thu, 04/07/2016 - 12:47 | logs    |
| Pierre    | [email protected]    | Fri, 04/01/2016 - 18:19 | logs    |
+-----------+-----------------------+-------------------------+---------+

Refine the delivered report

Next, just customize this reports, or create a clone from it that fits your needs. For example by using the query writing tool that comes with Forena, which is called the Forena Query Builder. This is a separated (sub-)module which can be enabled as per standard Drupal instructions to enable an additional module. For a video tutorial about this query writing tool, checkout Define data blocks with optional filters. Add any of the "custom fields" (as in your question) you want.

Set the report's export options

For the report you create, set the appropriate "document types" that fit your needs. Such as CSV, XLS, PDF, XLS, etc. For those document types you enable, an authorized report user will be able to click a hyperlink to export the report (in this case the list of users with the custom fields you added), in any of the formats you enabled within document types. Should you rather want JSON or XML format (as export format), that is also possible (just a slightly different approach, which is typically restricted to selected user roles only).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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