Wordpress has no feature to add custom image for the user. There are two way to display profile image:
1. Avatar: to change the avator, you should go Settings > Discussion
section of wordpress admin panel. Scroll down at bottom, you can see there are few default options of avator.
2. Gravatar: to use Gravator
image in user profile, you should sign up at https://en.gravatar.com
. Wordpress automatically grabs the image if sign up email address matches with 'Gravator' email.
Solution for you:
When you create user, you can add the image's url as meta field to the user. See the following example:
$user_name = 'userid';
$user_email = 'user_email@domain.com';
$user_id = username_exists( $user_name ); // check if user exist
if ( !$user_id and email_exists($user_email) == false ) { // if user does not exist
$random_password = wp_generate_password( $length=12, $include_standard_special_chars=false ); // generate random password
$user_id = wp_create_user( $user_name, $random_password, $user_email ); // creating new user
$img_url = 'http://orig15.deviantart.net/9faa/f/2011/006/e/9/there__s_something_about_molly_by_avator-d36l074.jpg'; // this is a sample image url but you should add the image url from json api
add_user_meta( $user_id, '_user_img_url', $img_url); // save the image url as meta field where meta key is _user_img_url
} else {
$random_password = __('User already exists. Password inherited.');
}
Now the question is, how you will retrieve image url:
// assume that the user id is 6
$user_id = 6;
// met key what we used to create user
$key = '_user_img_url';
// If true return value of meta data field
$single = true;
// get the image url
$user_img_url = get_user_meta( $user_id, $key, $single );
So, now you should echo
the image url in html
image tag:
<img src="<?=$user_img_url; ?>" alt=""/>
Hopefully it will help you.