Updating/ Auto Setting New Attributes for Existing Users

Permalink
We have close to 10,000 users on our website and occasionally we have the need to create new custom attributes and when we do so we need to automatically set these attributes. For the most part all of these are check boxes and while there is the "The checkbox will be checked by default." option, it still appears as though you have to manually go into each user and click on it before it becomes active.

Can anyone provide some insight on this? Is it actually set for each existing users automatically? If not, is there a quick and easy way to update all of the existing users?

 
JohntheFish replied on at Permalink Reply
JohntheFish
You could write a short job to loop through all users and set the attribute.

You could also use Magic Data + Magic Job + Black Magic Data to run such a job without writing any PHP, or run the Magic Data + Black Magic Data from the dashboard symbol tester and not need Magic Job.

The disadvantage of any such approach is that looping through 10,000 users takes a while, so could timeout. If you have complete control over the server, you can get round that by increasing php limits while you run the job.

If you don't have complete control of the server, you may need to write a queueable job.

Within the job or queueable job you should list users that don't have the attribute set. That way, should the job break part complete, you can re-run it and it will pick up from where it left off.

Adding support for queueable jobs to Magic Job is on my roadmap, but not yet implemented. Please PM me if you are seriously considering a Magic Data solution for this and I can advise further.

With any of the above, rather than listing users it may be more efficient to loop through user ids from 1..N and test if the user with that id exists. Such a method may also be better suited to breaking the 10,000 users up into smaller batches if you run into timeouts.

A totally different approach: export the users to a spreadsheet, add a column for the new attribute, then use one of the user import addons to re-import the users with the new attribute set.
RadiantWeb replied on at Permalink Reply
RadiantWeb
if you go to dashboard -> search users

you can check all (I think up to 500 at a time) and do a mass properties update with the pulldown above.

Then you'd only be doing that 20 times for 10,000 users. :-)

ChadStrat
JohntheFish replied on at Permalink Reply
JohntheFish
I didn't realise you could do that. It's better than my solution.