title: Fatal error: Uncaught Error: Cannot use object of type WP_Error as array
body: <p>Am trying to fetch user data from wordpress table. When I put the data into an array it shows me an fatal error. </p>
  
  <p>This is my php code:</p>
  
  <pre><code>$getuser_data = $wpdb-&gt;get_results($user_query);
  $userdata = array();
          foreach($getuser_data as $data)
          {
  
              $userfeed['username'] = $data-&gt;user_login;
              $userfeed['name'] = $data-&gt;user_email;
              $userfeed['email'] = $data-&gt;display_name;
  
              $userfeed['user_id'] = $data-&gt;ID;
              $userfeed['profile_pic'] = get_wp_user_avatar_src($data-&gt;ID);
              $usercount = count($getuser_data);
  
  
          }
          $userdata[] = $userfeed;
  </code></pre>
  
  <p>Its showing the fatal error Cannot use object of type WP_Error as array in last line $userdata[].
  Any help would be appreciated.
  Thanks in advance.</p>