简体   繁体   中英

Set user avatar from front end in wordpress

I am working on user registration page. When user upload the image then I attached that image in user meta by attachment id , now when user add the comment then his uploaded photo is not appearing in comment list beside his comment. After some search I got some information in avatar...but cant get any idea about how to upload avatar from front side?

<?php
if ( function_exists( 'get_avatar' ) ) {
  echo get_avatar( $user->user_email, 50);
 } else {
  //alternate gravatar code for < 2.5
  $grav_url = "http://www.gravatar.com/avatar.php?gravatar_id=
     " . md5($user->user_email) . "&default=" . urlencode($default) . "&size=" .   $size;
  echo "<img src='$grav_url' height='50px' width='50px' />";
}
?>

Please check with this code. This should work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM