Title: PHP Notices: Undefined offset&#8230;
Last modified: August 22, 2016

---

# PHP Notices: Undefined offset…

 *  Resolved [Denis Lam](https://wordpress.org/support/users/spiffyd/)
 * (@spiffyd)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/php-notices-undefined-offset/)
 * I found two consistent PHP notices you may want to do quick fixes for:
 * [21-Nov-2014 00:32:19 UTC] PHP Notice: Undefined offset: 0 in /public_html/wp-
   content/plugins/user-switching/user-switching.php on line 655
    [21-Nov-2014 00:
   32:19 UTC] PHP Notice: Undefined offset: 2 in /public_html/wp-content/plugins/
   user-switching/user-switching.php on line 635
 * [https://wordpress.org/plugins/user-switching/](https://wordpress.org/plugins/user-switching/)

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

 *  Plugin Author [John Blackbourn](https://wordpress.org/support/users/johnbillion/)
 * (@johnbillion)
 * WordPress Core Developer
 * [11 years, 6 months ago](https://wordpress.org/support/topic/php-notices-undefined-offset/#post-5502523)
 * Hi Denis,
 * This is most likely an issue caused by another plugin on your site. The notices
   you are seeing can only be caused by code which checks the `switch_to_user` capability
   without passing in a user ID.
 * Can you try disabling the other plugins on your site one by one to determine 
   which plugin is causing the notices to appear? Let me know which one it turns
   out to be.
 * John
 *  Thread Starter [Denis Lam](https://wordpress.org/support/users/spiffyd/)
 * (@spiffyd)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/php-notices-undefined-offset/#post-5502837)
 * Actually, I was able to resolve this issue by adding these PHP notice related
   conditions at the top of these functions.
 * Line 634 in `public function filter_user_has_cap()`:
 * `if ( !is_array($args) || empty($args[0]) || empty($args[1]) || empty($args[2])){
   return $user_caps; }`
 * Line 655 in `public function filter_map_meta_cap()`:
 * `if ( !is_array($args) || empty($args[0]) ) { return $required_caps; }`
 * Let me know what you think…
 *  Plugin Author [John Blackbourn](https://wordpress.org/support/users/johnbillion/)
 * (@johnbillion)
 * WordPress Core Developer
 * [11 years, 5 months ago](https://wordpress.org/support/topic/php-notices-undefined-offset/#post-5502843)
 * Hi Denis,
 * Yes, changing that code will get rid of the error message, but it is simply hiding
   the problem rather than fixing it. One of the other plugins on your site is causing
   these notices.
 * If possible, it would be great if you could disable your other plugins one by
   one until the error goes away, and let me know which plugin is causing it.
 * John
 *  [errorer](https://wordpress.org/support/users/errorer/)
 * (@errorer)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/php-notices-undefined-offset/#post-5502861)
 * I have same error, its plugin drag-drop-featured-image.
 * [13-Jan-2015 22:13:50 UTC] PHP Notice: Undefined offset: 0 in D:\WWW\Web\projects\
   wordpress\wp-content\plugins\user-switching\user-switching.php on line 655
 * [13-Jan-2015 22:13:50 UTC] PHP Stack trace:
 * [13-Jan-2015 22:13:50 UTC] PHP 1. {main}() d:\WWW\Web\projects\wordpress\wp-admin\
   plugins.php:0
 * [13-Jan-2015 22:13:50 UTC] PHP 2. require_once() d:\WWW\Web\projects\wordpress\
   wp-admin\plugins.php:10
 * [13-Jan-2015 22:13:50 UTC] PHP 3. require() D:\WWW\Web\projects\wordpress\wp-
   admin\admin.php:124
 * [13-Jan-2015 22:13:50 UTC] PHP 4. require_once() D:\WWW\Web\projects\wordpress\
   wp-admin\menu.php:269
 * [13-Jan-2015 22:13:50 UTC] PHP 5. do_action() D:\WWW\Web\projects\wordpress\wp-
   admin\includes\menu.php:149
 * [13-Jan-2015 22:13:50 UTC] PHP 6. call_user_func_array:{D:\WWW\Web\projects\wordpress\
   wp-includes\plugin.php:496}() D:\WWW\Web\projects\wordpress\wp-includes\plugin.
   php:496
 * [13-Jan-2015 22:13:50 UTC] PHP 7. WP_Drag_Drop_Featured_Image->add_admin_menu_page()
   D:\WWW\Web\projects\wordpress\wp-includes\plugin.php:496
 * [13-Jan-2015 22:13:50 UTC] PHP 8. add_options_page() D:\WWW\Web\projects\wordpress\
   wp-content\mu-plugins\drag-drop-featured-image\index.php:218
 * [13-Jan-2015 22:13:50 UTC] PHP 9. add_submenu_page() D:\WWW\Web\projects\wordpress\
   wp-admin\includes\plugin.php:1216
 * [13-Jan-2015 22:13:50 UTC] PHP 10. current_user_can() D:\WWW\Web\projects\wordpress\
   wp-admin\includes\plugin.php:1138
 * [13-Jan-2015 22:13:50 UTC] PHP 11. call_user_func_array:{D:\WWW\Web\projects\
   wordpress\wp-includes\capabilities.php:1380}() D:\WWW\Web\projects\wordpress\
   wp-includes\capabilities.php:1380
 * [13-Jan-2015 22:13:50 UTC] PHP 12. WP_User->has_cap() D:\WWW\Web\projects\wordpress\
   wp-includes\capabilities.php:1380
 * [13-Jan-2015 22:13:50 UTC] PHP 13. call_user_func_array:{D:\WWW\Web\projects\
   wordpress\wp-includes\capabilities.php:989}() D:\WWW\Web\projects\wordpress\wp-
   includes\capabilities.php:989
 * [13-Jan-2015 22:13:50 UTC] PHP 14. map_meta_cap() D:\WWW\Web\projects\wordpress\
   wp-includes\capabilities.php:989
 * [13-Jan-2015 22:13:50 UTC] PHP 15. apply_filters() D:\WWW\Web\projects\wordpress\
   wp-includes\capabilities.php:1360
 * [13-Jan-2015 22:13:50 UTC] PHP 16. call_user_func_array:{D:\WWW\Web\projects\
   wordpress\wp-includes\plugin.php:213}() D:\WWW\Web\projects\wordpress\wp-includes\
   plugin.php:213
 * [13-Jan-2015 22:13:50 UTC] PHP 17. user_switching->filter_map_meta_cap() D:\WWW\
   Web\projects\wordpress\wp-includes\plugin.php:213
 *  Plugin Author [John Blackbourn](https://wordpress.org/support/users/johnbillion/)
 * (@johnbillion)
 * WordPress Core Developer
 * [11 years, 4 months ago](https://wordpress.org/support/topic/php-notices-undefined-offset/#post-5502862)
 * These PHP notices are caused by a bug in the drag-drop-featured-image plugin.
   It’s using boolean `true` as a capability (rather than something like `manage_options`),
   which is incorrect.
 * I’ve just released an update to User Switching which avoids these PHP notices,
   even though the problem isn’t actually with User Switching itself.

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

The topic ‘PHP Notices: Undefined offset…’ is closed to new replies.

 * ![](https://ps.w.org/user-switching/assets/icon.svg?rev=3193956)
 * [User Switching](https://wordpress.org/plugins/user-switching/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/user-switching/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/user-switching/)
 * [Active Topics](https://wordpress.org/support/plugin/user-switching/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/user-switching/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/user-switching/reviews/)

 * 5 replies
 * 3 participants
 * Last reply from: [John Blackbourn](https://wordpress.org/support/users/johnbillion/)
 * Last activity: [11 years, 4 months ago](https://wordpress.org/support/topic/php-notices-undefined-offset/#post-5502862)
 * Status: resolved