Home › Forums › Plugin Support › Avatar Field does not replace the avatar photo.
Tagged: avatar
- This topic has 8 replies, 3 voices, and was last updated 11 years, 11 months ago by krla.
-
AuthorPosts
-
May 9, 2012 at 2:17 pm #1201May 9, 2012 at 3:21 pm #1203KhaledMember
Hello,
Which version of user-meta-pro you are using now? could you please post the url here.Thanks.
May 9, 2012 at 5:46 pm #1208mhuntdesignMemberThe latest rc3 from may 4th. I can’t post the url to the dev site publicly. But Basically what I am trying to do is use the avatar field to update the avatar. So it would have to replace the gravatar I suppose.. much like what buddypress does. So what you have here for the account photo: http://user-meta.com/account/ and on the comments on this site for instance, I would assume the expectation of the avatar field is to replace the avatar. That does work but I only see the avatar updated when I go to the WP backend under Users. Is anything anything special to get it ti work? Like I said the normal get_avatar’ function did not work for me. it simply shows the old avatar.
Thanks for taking a look!
May 9, 2012 at 7:37 pm #1211KhaledMemberHello, normal ‘get_avatar’ function should work. we have share the same function for both front-end and back-end. Please check are there any other plugin in your system are overwrite ‘get_avatar’ filter.
Ty
May 10, 2012 at 9:21 am #1238mhuntdesignMemberI did a few more tests. It works for people that already have a gravatar. If the user does not have a gravatar, then it does not replace the existing. The new image does show on the backend, but not on the front using the get_avatar function.
May 10, 2012 at 1:21 pm #1240mhuntdesignMemberOk so I made some progress with this one. I had to use a different piece of code.
I had to do some research initially to figure out how to display user meta data. Since I new what function to use for that, I was actually only a step away.
I looked on the actual form html code to see the name attribute of an existing custom field then I searched for what was set for the avatar.. which was user_avatar.
Here is the code if it shows through properly:
But first the steps:
1) Get the author id.
2) Get the value of the user_avatar field in the database
3) Since the value starts at a subdirectory of uploads… output that path
as part of the src attribute value.
That does it.
$curauth = (get_query_var('author_name')) ? get_user_by('slug', get_query_var('author_name')) : get_userdata(get_query_var('author'));$author_id = $curauth -> ID;
$user_avatar = get_usermeta($author_id,'user_avatar');
<img src="/wp-content/uploads/" width="220" height="220" />The only thing that is not resolved at the point is that the avatars do not update in the comments section for anyone who does not currently use a gravatar icon with their email.
May 10, 2012 at 3:26 pm #1243KhaledMemberHello,
Please download the version again. Let us know if it is working for you.
Thanks.
May 10, 2012 at 4:08 pm #1244mhuntdesignMemberThank you! That fixed the comments avatars. They show up now in the comments. However, It would be great if the avatars changed throughout. The code I submitted works though if someone wants to use this in their template:
echo get_user_meta(get_the_author_meta('ID'), 'user_avatar', true);
Instead of the usual:
echo get_avatar( get_the_author_meta('ID'), 220, '', '' );
Like I said this only affects users that already have a gravatar existing from the start. (from gravatar.com)
I have things working the way I need on my end so I am very pleased. But ideally we would want to use the get_avatar function. Now, I tried this in and outside of a loop and the same things happens.
Great plugin. Thanks for your help!
December 5, 2012 at 7:52 pm #2595krlaMemberHi,
I have the problem with users that don’t have any avatar photo assigned.
When I upload a new avatar, file is uploaded ok but the avatar has not been swapped by the new one.
I have detect that in the file /user-meta/views/showFile.php always shows the $avatar detected in line7… but not detects that are a new file uploaded!!!
Please any help asap!!??
Thanks!
-
AuthorPosts
- You must be logged in to reply to this topic.