How to set gravatar picture programmatically?

2.3k Views Asked by At

I'm using gravatar to display my user contact in WordPress but I want to allow them to change their picture. I don't see any way to set it with the API.

I'm not using Woocommerce and I already know to fetch the avatar. Is it possible?

Edit

After some search, I found in the api documentation, this section : https://fr.gravatar.com/site/implement/xmlrpc/

But I still don't understand how to implement it with my WordPress avatar.

2

There are 2 best solutions below

1
Rajdeep Tayde On

You can simply use plugin https://wordpress.org/plugins/wp-user-avatar/ and use their shortcode wherever you want to show the upload picture form just install the plugin and

use

echo do_shortcode('[avatar_upload]');

It will show the form to upload the picture

1
red On

I think that gravatar not have api to let you update it from external site but maybe there is other solutions to feet your needs.

You can do the following: let the user add a profile picture directly in your site using a plugin or by developing your own solution, then check if user has defined his avatar and print it, if not print gravatar or nothing.

There is a lot of plugin to manage avatar, check for example this:

For what about the custom development you can use for example a form builder like formidable form to let the user upload some image: Here an example of workflow: