WordPress.org

Ready to get started?Download WordPress

Forums

JSON API
getting avatar image output in JSON (2 posts)

  1. 7hegodfather
    Member
    Posted 1 year ago #

    is there anyway to display my avatar image url from my JSON output?

    http://wordpress.org/extend/plugins/json-api/

  2. jibbius
    Member
    Posted 1 year ago #

    Are you using BuddyPress also?
    Something like this perhaps?

    public function user_listing() {
            global $json_api;
            $key = null;
            extract($json_api->query->get(array('key')));
    
    // optional - you may want to validate a "key" parameter?
    //        authorise($key) ? die('Access denied') : false;
    
    // Which users do you want?
            $args = array('role'=>'subscriber');
            $my_users = get_users( $args );
    
            foreach($my_users as $handle => $my_user){
               $$my_users[$my_user->ID]= array(
                    'UserID'=>$my_user->ID,
                    'UserName'=>$my_user->display_name,
                    'AvatarImageURL'=>bp_core_fetch_avatar(array('html'=> false,'item_id'=>$my_user->ID,'object'=>'user'))
                );
    
            }
    
            return array(
                "users" => $my_users,
                "message" => ''
            );
        }

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.