Title: Error: Invalid foreach() argument
Last modified: September 1, 2016

---

# Error: Invalid foreach() argument

 *  [chenryahts](https://wordpress.org/support/users/chenryahts/)
 * (@chenryahts)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/error-invalid-foreach-argument/)
 * Line 393 of wp-power-stats-admin produces this error. When I introduce a check
   for array, it goes away:
 *     ```
       if (is_array ($role) ) {
               foreach ($role->capabilities as $key => $capability) {
                   return $key;
               }
       		}
       ```
   
 * [https://wordpress.org/plugins/wp-power-stats/](https://wordpress.org/plugins/wp-power-stats/)

Viewing 1 replies (of 1 total)

 *  Plugin Author [artifex404](https://wordpress.org/support/users/artifex404/)
 * (@artifex404)
 * [9 years, 8 months ago](https://wordpress.org/support/topic/error-invalid-foreach-argument/#post-8250866)
 * Thanks for the heads up! In fact the $role variable should be an object, or null
   if the role was not found. I’ll add the check in the next update.

Viewing 1 replies (of 1 total)

The topic ‘Error: Invalid foreach() argument’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/wp-power-stats_f8f8f8.svg)
 * [WP Power Stats](https://wordpress.org/plugins/wp-power-stats/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-power-stats/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-power-stats/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-power-stats/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-power-stats/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-power-stats/reviews/)

## Tags

 * [array](https://wordpress.org/support/topic-tag/array/)

 * 1 reply
 * 2 participants
 * Last reply from: [artifex404](https://wordpress.org/support/users/artifex404/)
 * Last activity: [9 years, 8 months ago](https://wordpress.org/support/topic/error-invalid-foreach-argument/#post-8250866)
 * Status: not resolved