Title: Undefined offset: 0
Last modified: August 22, 2016

---

# Undefined offset: 0

 *  Resolved [signo](https://wordpress.org/support/users/signo/)
 * (@signo)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/undefined-offset-0-2/)
 * When DEBUG is turned on i get error Undefined offset: 0 at line 655 of file user-
   switching.php
 *     ```
       if ( ( 'switch_to_user' === $cap ) and ( $args[0] == $user_id ) ) {
       			$required_caps[] = 'do_not_allow';
       }
       ```
   
 * If you add a test for empty at line 655 the error goes away
 *     ```
       if ( ( 'switch_to_user' === $cap ) and ( !empty( $args ) && $args[0] == $user_id ) ) {
       			$required_caps[] = 'do_not_allow';
       }
       ```
   
 * [https://wordpress.org/plugins/user-switching/](https://wordpress.org/plugins/user-switching/)

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

 *  Plugin Author [John Blackbourn](https://wordpress.org/support/users/johnbillion/)
 * (@johnbillion)
 * WordPress Core Developer
 * [11 years, 3 months ago](https://wordpress.org/support/topic/undefined-offset-0-2/#post-5867815)
 * This notice indicates that another plugin on your site is calling `current_user_can('
   switch_to_user' )` without passing in a user ID. If I add a test for empty, it
   just masks the problem rather than identifying the cause.
 * Can you disable your other plugins one by one until the error disappears? Let
   me know which plugin is causing the notice.
 *  Plugin Author [John Blackbourn](https://wordpress.org/support/users/johnbillion/)
 * (@johnbillion)
 * WordPress Core Developer
 * [11 years, 2 months ago](https://wordpress.org/support/topic/undefined-offset-0-2/#post-5868099)
 * Marking this as resolved because there’s a good chance that the [Admin Bar User Switching plugin](https://wordpress.org/plugins/admin-bar-user-switching/)
   was causing this notice.

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

The topic ‘Undefined offset: 0’ 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/)

 * 2 replies
 * 2 participants
 * Last reply from: [John Blackbourn](https://wordpress.org/support/users/johnbillion/)
 * Last activity: [11 years, 2 months ago](https://wordpress.org/support/topic/undefined-offset-0-2/#post-5868099)
 * Status: resolved