Export User Information List

Okay, here are some more improvements:

  • Added custom user fields.

  • Added header title for each column.

  • Added following additional user fields: trust_level, active, admin, moderator, ip_address.


The file extension for me is .csv.gz (user-list-150521-195707-1.csv.gz – 2.7 KB), and when I open in Excel it displays random characters. Expected behavior?

I’m not familiar with Excel to know if it unzips compressed files, but it sounds like it didn’t.

Try unzipping it to a “.csv” file and try it again.

1 Like

Thanks @Mittineague I guess I’ll need a file extraction app, will hunt around as I don’t think it’s native on win. 8.1.

It’s just GZIP compressed, you can use WinRAR

1 Like

I have PHP on localhost and hard-code the filenames as needed (yes, hacky, but I don’t use it often enough to bother making it nicer)

$readfilename = "user-archive-Mittineague-150222-090655-52.csv.gz";
$writefilename = "user-archive-Mittineague-150222-090655-52.csv";

$filecontent = "";

$filepointer = gzopen($readfilename, "rb");
while (!gzeof($filepointer)) {
	$contentline = gzgets($filepointer);
	$filecontent .= $contentline;

$filehandle = fopen($writefilename, "wb");
fwrite($filehandle, $filecontent);

@techAPJ would it be possible to add last seen date in the user export? This would be immensely useful for our community.

Okay, I just added three new fields: last_seen_at, last_posted_at, last_emailed_at to the user list export!


awesome - many, many thanks. :sunny:

1 Like

Is there a way to access this via the API. Since you can not access the full user list via the api I could use this for my purpose. I need to compare and clean the users on an instance based on and external list.

@techAPJ would it be possible to add location in the user export? This would help us to identify people by country (we use SSO to populate the location field with the country of the user) so we can alert them about opportunities in their country. As explained in this topic.


Okay, I added three more fields to user list export: location, website, views. :sunny:


fabulous. many thanks! :sunflower:

1 Like

@techAPJ is the time spent reading recently (as visible in user cards) a number stored in the user table? If so, would you be willing to also add it to the user export?

I’m trying to MVP a way to get this:

No, it’s not stored in a table. It is calculated at runtime.


ah - got it. thanks! back to the drawing board, then. :seedling:

There is no option to export users in current version of discource. I am running version 2.2.0-beta3. Does this mean there are no ways to do that now, or has it moved to some other place?

UPDATE: Sorry, I found this option, was hidden, I had to scroll to see it.

1 Like

How to reduce link lifetime? And delete files * .gz

You can’t. It’s hardcoded to be deleted after 2 days



class UserExport < ActiveRecord::Base

  def self.remove_old_exports
    UserExport.where('created_at < ?', 2.days.ago).find_each do |user_export|
      upload_id = "#{user_export.upload_id}"
      data = Upload.where(id: upload_id).take
      file_path = "#{UserExport.base_directory}/#{data}"
if data 
      File.delete(file_path) if File.exist?(file_path)


  def self.base_directory
    File.join(Rails.root, "public")