Title: PHP Warning in foreach
Last modified: August 21, 2016

---

# PHP Warning in foreach

 *  [Mike Auteri](https://wordpress.org/support/users/mauteri/)
 * (@mauteri)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/php-warning-in-foreach/)
 * Not sure if anyone else is experiencing this, but when logging into WordPress,
   I get the following PHP warning:
 * Warning: Invalid argument supplied for foreach() in /Applications/MAMP/htdocs/
   raspy-robbin/wp-content/plugins/radio-station/radio-station.php on line 179
 * I took a look at the foreach() and found that doing an is_array() check beforehand
   fixes the issue:
 * //determine which roles should have full access aside from administrator
    $add_roles
   = array(‘administrator’); if(is_array($wp_roles->roles)) { foreach($wp_roles-
   >roles as $name => $role) { foreach($role[‘capabilities’] as $capname => $capstatus){
   if($capname == “publish_shows” && ($capstatus == 1 || $capstatus == true)) { 
   $add_roles[] = $name; } } } }
 * If you can reproduce, you might want to add this check into the plugin with your
   next update. Thanks!
 * [http://wordpress.org/plugins/radio-station/](http://wordpress.org/plugins/radio-station/)

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [Nikki Blight](https://wordpress.org/support/users/kionae/)
 * (@kionae)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/php-warning-in-foreach/#post-4317733)
 * Thanks for the heads up. I’ll get that added into the next version.
 *  Thread Starter [Mike Auteri](https://wordpress.org/support/users/mauteri/)
 * (@mauteri)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/php-warning-in-foreach/#post-4317734)
 * Awesome! Is the fix in 1.6.2 or going into 1.6.3? Thx.
 *  [Nikki Blight](https://wordpress.org/support/users/kionae/)
 * (@kionae)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/php-warning-in-foreach/#post-4317735)
 * It will be in 1.6.3.
 *  Thread Starter [Mike Auteri](https://wordpress.org/support/users/mauteri/)
 * (@mauteri)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/php-warning-in-foreach/#post-4317736)
 * Cool, thx. I’ll patch 1.6.2 then.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘PHP Warning in foreach’ is closed to new replies.

 * ![](https://ps.w.org/radio-station/assets/icon-256x256.png?rev=2905948)
 * [Radio Station by netmix® - Manage and play your Show Schedule in WordPress!](https://wordpress.org/plugins/radio-station/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/radio-station/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/radio-station/)
 * [Active Topics](https://wordpress.org/support/plugin/radio-station/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/radio-station/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/radio-station/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [Mike Auteri](https://wordpress.org/support/users/mauteri/)
 * Last activity: [12 years, 6 months ago](https://wordpress.org/support/topic/php-warning-in-foreach/#post-4317736)
 * Status: not resolved