Rake task for merging users

I have spent some time using this super handy user merge rake command combined with @gerhard’s rails commands to remove secondary emails. Thank you both.

These commands have become an important and handy part of my workflow to bring back defunct users who have become unreachable, or to invite people who attend or apply for our events to join our community. Often there is a need to change the email address of the existing account, while retaining the correspondence with a new, staged user.

I do share @pfaffman’s challenge.

The answer for now seems to be to merge the user, delete the secondary email address of the remaining user using @gerhard’s rails commands, then change the email address via the web interface. (in my case it’s via wordpress SSO). Presto, done. But it’s three commands involving some copy pasting and is a bit time consuming.

Some suggestions follow. Curious to hear reactions.

How about a users:swapemail command to run before the merge?

rake users:swapemail[user1,user2]
rake users:merge[user1,user2] 

Add ability to edit secondary email addresses via the admin UI?

I have SSO on my site so can’t use this, but for those who don’t it would be useful to be able to edit the primary and secondary email addresses directly via the user admin.

Add ability to update secondary email via SSO?

This might already be possible via API, but support for a secondary email field would need to be added to the SSO provider, in my case wordpress.

Move primary email to secondary when primary email is changed?

Perhaps a simpler, more sustainable long-term solution that doesn’t require alot of other changes would be to simply change it so when a user or admin (via web or SSO) changes the primary email, it moves the old email to the secondary email field first. This could be enabled with an admin site setting.

8 Likes