.csv upload for bulk user custom field changes

It would be super helpful to have the ability to upload a .csv (much like bulk invites) which contained the following:

  1. username
  2. custom field name
  3. custom field value

And then have this data directly applied to the users’ accounts. Only if the username and custom field name are valid of course!

This would help enormously with data tidy-up exercises and migrations, which appear to be darn tricky with user custom fields.

If it’s for an import then it’s easy to do it in the importer.

You might also use the API.

Is hard to imagine acsv upload solution that would be easier.

1 Like

Well, my use case is for restoring some user custom fields which I inadvertently wiped for a bunch of users (see Problem with manipulating custom user fields from the Rails console). I’ve got the backup on a staging site, and I’ve also got them as a .csv

When you say ‘easy’ I’m guessing you mean it would take you a few hours to bash something out that would do the job. Can you give me a cost estimate?

Send me an email with details.

Jay has delivered the goods:

It requires some competence with Linux / Bash in order to use it, and I’d strongly recommend doing a backup first and doing it at a quiet time as you can royally stuff up your user data if not careful. I trialled it on a staging server before using it on our production site.

You might find this Data Explorer query useful in order to get the existing data for the user_field that you are targeting:

--[params]
-- string :ucf_name = user_field_1

SELECT
    user_id, value as ":ucf_name"
    
FROM user_custom_fields

WHERE name = :ucf_name
ORDER BY user_id asc

Note that you’ll have to remove the ' from either side of the field name in the .csv as I couldn’t work out how to stop the query including them.

3 Likes

Thank you for creating this script:

It would be nice if there was simply a upload option when creating the user field
or an upload when creating tag groups.

Can you upload a picture that shows how the data should be formatted in excel.

Thank you!

Column 1 Column 2 Column 3
user_id user_field_1 user_field_3
4 value hello
3 another value world
6 still another banana
1 Like

Thank you!

1 Like