• patrioticcow

    (@patrioticcow)


    below i return the avatar and email (because that is what i need)
    but you can make the email optional

    var $email;       // String
    var $avatar;     // String
    
    function JSON_API_Author($id = NULL)
    {
    	...
    	$this->set_value('email', 'user_email');
    	$this->avatar = $this->getAvatar();
    
    	$this->set_author_meta();
    }
    
    function getAvatar()
    {
    	$avatar = get_avatar($this->email);
    	preg_match("/src=['\"](.*?)['\"]/i", $avatar, $matches);
    
            // i return only the link, but you can return the array
    	return isset($matches[1]) ? $matches[1] : '';
    }

    https://ww.wp.xz.cn/plugins/json-api/

The topic ‘adding gravatar’ is closed to new replies.