Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have JSON-API installed and I'm using a custom controller to get all users with the role 'editor'. I also have WP-User-Avatar installed so the editors can upload their own images instead of using Gravatar. I have two installations, one test server where the api returns the images and the production server, where I get 'false' for images. Here is the code from the controller:

public function get_editors_with_image() {

global $json_api, $wp_query;

$args = array('role' => 'editor');
$user_query = new WP_User_Query( $args );
$user_results = $user_query->results;

$editors = array();

foreach ($user_results as $key => $value) {
  $current_id = $value->data->ID;
  $editors[$key]['id'] = $current_id;
  $editors[$key]['url'] = $value->data->user_url;
  $editors[$key]['display_name'] = $value->data->display_name;
  $editors[$key]['description'] = get_the_author_meta('description', $current_id);

  $editors[$key]['image'] = get_avatar($current_id, 400);
}

return array(
  "editors" => $editors
);

}

This is the outcome on the testserver:

{
  "status": "ok",
  "editors": [
    {
      "id": "2",
      "url": "http:\/\/example.de",
      "display_name": "Example",
      "description": "Hello, is it me you're looking for?",
      "image": "<img src=\"http:\/\/example.com/path to image\" width=\"225\" height=\"400\" class=\"avatar avatar-400 wp-user-avatar wp-user-avatar-400 alignnone photo\" \/>"
    },
    {
      "id": "3",
      "url": "",
      "display_name": "HEllo World",
      "description": "",
      "image": "<img src=\"http:\/\/example.com/path/to/other/image\" width=\"225\" height=\"400\" alt=\"HEllo World\" class=\"avatar avatar-400 wp-user-avatar wp-user-avatar-400 alignnone photo\" \/>"
    }
  ]
}

But on the production server, I get this:

{
  "status": "ok",
  "editors": [
    {
      "id": "16",
      "url": "",
      "display_name": "foo bar",
      "description": "",
      "image": false
    },
    {
      "id": "21",
      "url": "",
      "display_name": "bar foo",
      "description": "",
      "image": false
    }
  ]
}

What could cause this? Could it be some setting on the production server I haven't thought about?

share|improve this question
    
Add var_dump( $user_query ); to see if you get any results at all. And activate debugging. –  kaiser Jan 14 at 13:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.