Skip to content

Automatically replaces Wordpress user avatars with custom images based on username. It searches the gallery for username.jpg and replaces the avatar.

License

Notifications You must be signed in to change notification settings

1xn/wp-avatar-filter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

wp-avatar-filter

The wp-avatar-filter plugin for WordPress provides a filter hook that allows you to replace user avatars with custom images based on username. It searches the gallery for username.jpg and replaces the avatar with that image. Note that your WordPress site must have the media upload setting not set to date upload for this to work.

Installation

Download

  • Just download the .zip file, edit the example.com URL inside the php file with your URL
  • Compress it into a .zip file again with your edits. Upload the zip file directly to the WordPress admin interface.
  • Activate the wp-avatar-filter plugin if not activated on the install.
  • Make sure in Wordpress Settings - Media you have checked OFF the option to organize uploads by date.

Usage

Once the plugin is installed and activated, you can upload an image with the filename yourusername.jpg and the get_avatar_data filter hook will be applied to WordPress automatically, all the user avatars will be replaced with the corresponding username.jpg file from the media gallery.

Notes

It took me a little while to figure out how to use the get_avatar_data filter hook, as the WordPress API documentation can be vague at times.

So big thanks to Adi Kusuma for the help! https://stackoverflow.com/users/10203981/adi-kusuma

Once you get it working, it's a powerful tool to automate bulk user creation in Wordpress. Tested on a Wordpress installation with over 200 users. It works dynamically, so you can replace images just by deleting the old one, and uploading a new one with the title of your username like username.jpg

License

This plugin is licensed under the GPL 2.0 or later.

About

Automatically replaces Wordpress user avatars with custom images based on username. It searches the gallery for username.jpg and replaces the avatar.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages