WordPress itself does not include a way for users to upload their own avatars. Instead users are encouraged to use the Gravatar service. There have been many discussions about building in an avatar upload feature, and I think it may actually make it into a future release of WP any day now. In the meantime, there is a plugin for that. In fact, there are a few plugins for that.
While Paid Memberships Pro works well (as far as I know) with the most popular avatar plugins, we wanted to be able to recommend one of them above the others. We wanted one that worked as seamlessly as possible with our frontend profile page and directory plugin.
Taking Control of the Basic User Avatars Plugin
Last year, we reached out to Jared Atchison about taking over maintenance of the Basic User Avatars plugin. There were a few minor bugs and enhancements we had done for our customers. We did a pull request against the GitHub repository and offered to maintain the WordPress.org repository for the plugin going forward. Jared said yes, and gave us access on GitHub and WordPress.org.
To be clear, our intention still is to keep Basic User Avatars as a simple avatar upload plugin until such functionality is made available in the core WordPress software. Many of our customers require this functionality for their site, and we like being able to recommend a plugin we know we can fix if an update to PMPro, WordPress, or any popular plugin breaks that functionality.
WP User Avatar Becomes ProfilePress
One plugin we used to recommend for avatar uploads was called “WP User Avatar”. We noticed a couple years ago that it had been acquired by a competing membership plugin. We thought the new owners might add features that made it more than the single use plugin it was, and so we stopped recommending it, but we never expected them to do what they did this week.
Basically the plugin that was WP User Avatar is now a lite version of the ProfilePress plugin, with a lot of features that conflict with PMPro, or features you just don’t want if you only want avatar uploads for your site. WP Tavern has covered the release and confusion around it well.
Migrating from WP User Avatar to Basic User Avatars
Today we released version 1.0.5 of Basic User Avatars. This version added a feature to automatically convert avatars formerly loaded through the WP User Avatar plugin to the Basic User Avatars format. This means that you can disable WP User Avatar, activate Basic User Avatars, and have a seamless transition for existing avatars in your site. Be sure to update any avatar upload form that used the [avatar_upload]
shortcode to use our shortcode: [basic-user-avatars]
.
Digging into the Code
Some of the developers and product folks reading this might be interested in the thought process behind how we decided to code the migration. At first we built a system that checked the user meta table to see if the WP User Avatar plugin had been used before. If so, we displayed a notification with a link to begin a migration process that loaded the avatar data from user meta in the old format and then saved it into the format used by Basic User Avatars.
This worked well, but when we tested it out on our staging site with over 100k users, the migration was slow. We were working on ways to increase the performance and reliability of the migration, when we realized (really it was our Lead Developer David Parker) that instead of migrating all avatars at once, we can instead migrate the avatars “on the fly” as they are loaded on the site.
We removed the migration code and instead added some code to our get_avatar
filter that looks for WP User Avatar data if no Basic User Avatars data exists. This adds a fraction of a second of compute time the first event that any old format avatar is loaded, but in practice, this shouldn’t impact the perceived performance of the site, while still making sure the avatars that matter are updated.
This is a useful pattern that can be applied in any situation where you need to convert data from one format to another. WordPress does something similar when it generates resized versions of images on the fly. We do something similar with the license keys for PMPro members on this site. The pattern can be described as “write a function to get the thing; if the thing doesn’t exist, generate it”.
I hope this post explained some of the history of how we came to maintain the Basic User Avatars plugin, our plans for that plugin, some information about the WP User Avatar update, how to migrate from WPUA to BUA, and some insight into how we coded the migration.