WordPress.org

Ready to get started?Download WordPress

Plugin Directory

WP User Avatar

Use any image from your WordPress Media Library as a custom user avatar. Add your own Default Avatar.

Visit WP User Avatar for more information and documentation.

  1. Download, install, and activate the WP User Avatar plugin.
  2. On your profile edit page, click "Edit Image".
  3. Choose an image, then click "Select Image".
  4. Click "Update Profile".
  5. Upload your own Default Avatar in your WP User Avatar settings (optional). You can also allow Contributors & Subscribers to upload avatars and disable Gravatar.
  6. Choose a theme that has avatar support. In your theme, manually replace get_avatar with get_wp_user_avatar or leave get_avatar as-is. Read about the differences here.
  7. You can also use the [avatar_upload] and [avatar] shortcodes in your posts. These shortcodes will work with any theme, whether it has avatar support or not.

Example Usage

Posts

Within The Loop, you may be using:

<?php echo get_avatar(get_the_author_meta('ID'), 96); ?>

Replace this function with:

<?php echo get_wp_user_avatar(get_the_author_meta('ID'), 96); ?>

You can also use the values "original", "large", "medium", or "thumbnail" for your avatar size:

<?php echo get_wp_user_avatar(get_the_author_meta('ID'), 'medium'); ?>

You can also add an alignment of "left", "right", or "center":

<?php echo get_wp_user_avatar(get_the_author_meta('ID'), 96, 'left'); ?>

Author Page

On an author page outside of The Loop, you may be using:

<?php
  $user = get_user_by('slug', $author_name); 
  echo get_avatar($user->ID, 96);
?>

Replace this function with:

<?php
  $user = get_user_by('slug', $author_name);
  echo get_wp_user_avatar($user->ID, 96);
?>

If you leave the options blank, WP User Avatar will detect whether you're inside The Loop or on an author page and return the correct avatar in the default 96x96 size:

<?php echo get_wp_user_avatar(); ?>

The function get_wp_user_avatar can also fall back to get_avatar if there is no WP User Avatar image. For this to work, "Show Avatars" must be checked in your WP User Avatar settings. When this setting is enabled, you will see the user's Gravatar avatar or Default Avatar.

Comments

For comments, you might have in your template:

<?php echo get_avatar($comment, 32); ?>

Replace this function with:

<?php echo get_wp_user_avatar($comment, 32); ?>

For comments, you must specify the $comment variable.

Other Available Functions

[avatar_upload] shortcode

You can use the [avatar_upload] shortcode to add a standalone uploader to a front page or widget. This uploader is only visible to logged-in users. If you want to integrate the uploader into a profile edit page, see Other Notes.

You can specify a user with the shortcode, but you must have edit_user capability for that particular user.

[avatar_upload user="admin"]

[avatar] shortcode

You can use the [avatar] shortcode in your posts. It will detect the author of the post or you can specify an author by username. You can specify a size, alignment, and link, but they are optional. For links, you can link to the original image file, attachment page, or a custom URL.

[avatar user="admin" size="medium" align="left" link="file" /]

You can also add a caption to the shortcode:

[avatar user="admin" size="medium" align="left" link="file"]Photo Credit: Your Name[/avatar]

Note: If you are using one shortcode without a caption and another shortcode with a caption on the same page, you must close the caption-less shortcode with a forward slash before the closing bracket: [avatar /] instead of [avatar]

get_wp_user_avatar_src

Works just like get_wp_user_avatar but returns just the image src. This is useful if you would like to link a thumbnail-sized avatar to a larger version of the image:

<a href="<?php echo get_wp_user_avatar_src($user_id, 'large'); ?>">
  <?php echo get_wp_user_avatar($user_id, 'thumbnail'); ?>
</a>

has_wp_user_avatar

Returns true if the user has a WP User Avatar image. You must specify the user ID:

<?php
  if ( has_wp_user_avatar($user_id) ) {
    echo get_wp_user_avatar($user_id, 96);
  } else {
    echo '<img src="my-alternate-image.jpg" />';
  }
?>

Requires: 3.6 or higher
Compatible up to: 3.9.1
Last Updated: 2014-6-26
Downloads: 493,193

Ratings

4 stars
4.7 out of 5 stars

Support

4 of 24 support threads in the last two months have been resolved.

Got something to say? Need help?

Compatibility

+
=
Works!

9 people say it works.
1 person says it's broken.

100,2,2 100,1,1 100,8,8 100,1,1 100,2,2 50,2,1 50,2,1 100,1,1 100,3,3 50,2,1 100,1,1 100,1,1 67,3,2
100,1,1 100,2,2 100,1,1
100,1,1 100,1,1 100,2,2
100,1,1 100,1,1 100,1,1 100,2,2
100,2,2 100,1,1 100,1,1 100,1,1
100,3,3 100,1,1 100,2,2
100,3,3 100,3,3 100,2,2 67,3,2 100,2,2 100,1,1 100,2,2
100,2,2 100,1,1
0,1,0 100,1,1 100,1,1 100,1,1 100,1,1 0,1,0 100,1,1
90,10,9