Hello,
i want to export the email-addresses of my users by using the export-function inside the user-module. But unfortunately the email-address is not included in the csv-file.
Does anyone know how to include the email address or the right sql-qeury to get this result?
Thank you so much and best regards
Simon
I found the answer from pgr.
https://pgorod.github.io/How-Emails-Stored/
SELECT users.user_name, email_address
FROM users
LEFT JOIN email_addr_bean_rel ON email_addr_bean_rel.bean_id = users.id
AND email_addr_bean_rel.bean_module = ‘Users’
AND email_addr_bean_rel.primary_address =1
AND email_addr_bean_rel.deleted =0
LEFT JOIN email_addresses ON email_addresses.id = email_addr_bean_rel.email_address_id
AND email_addresses.deleted =0
WHERE STATUS = ‘active’
the where at the end filters for only status=active.
To understand how to include additional fields in Export, Please check the file modules/Accounts/Account.php
Here there are 3 things to note.
- $additional_column_fields
- $relationship_fields
- function create_export_query
in the first two Arrays, the columns are identified, which are then used in the query of the create_export_query function.