Get User ID

  $user_id = get_current_user_id();

Get username

  //For the current user
  $current_user = wp_get_current_user();
  $username = $current_user->user_login;

  //For a different user
  $selected_user = get_userdata($UserId);
  $user_login = $selected_user->user_login;

Get Avatar

HTML ready code to display it
$AvatarHtml = get_avatar($UserId, 32);  //2nd argument is optional size
Avatar URL
$AvatarUrl = get_avatar_url($UserId);
Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.

Comments

Your email address will not be published. Required fields are marked *