• stenaols

    (@stenaols)


    Hi. When opening wp-adming I get this error:

    Notice: Undefined offset: 1 in /home3/mytosno/public_html/wp-content/themes/mytos/classes.php on line 74

    Warning: Cannot modify header information – headers already sent by (output started at /home3/mytosno/public_html/wp-content/themes/mytos/classes.php:74) in /home3/mytosno/public_html/wp-includes/pluggable.php on line 881

    I have deactivated all plugins, but still get the error.

    Any ideas?

    Sten

Viewing 4 replies - 1 through 4 (of 4 total)
  • It is in your theme– “wp-content/themes/mytos/classes.php” on line 74. It is a non-fatal error so it should work with define('WP_DEBUG',false); as it should be on a live site. It should also be an easy proper fix if you want to paste lines 70-80 or so of “wp-content/themes/mytos/classes.php”.

    Thread Starter stenaols

    (@stenaols)

    Hi. Here is lines 70 – 80:

    $this->user->active_blog = get_active_blog_for_user( get_current_user_id() );
    			$this->user->domain = empty( $this->user->active_blog ) ? user_admin_url() : trailingslashit( get_home_url( $this->user->active_blog->blog_id ) );
    			$this->user->account_domain = $this->user->domain;
    		} else {
    			$this->user->active_blog = $this->user->blogs[get_current_blog_id()];
    			$this->user->domain = trailingslashit( home_url() );
    			$this->user->account_domain = $this->user->domain;
    		}
    		$this->user->locale = get_locale();
    
    		add_action( 'wp_head', 'wp_admin_bar_header' );
    Thread Starter stenaols

    (@stenaols)

    Hi again. Changed WB_DEBUG to false, and then it worked!. Thanks a lot!

    Yes, it works but it isn’t fixed.

    The problem is here: $this->user->active_blog = $this->user->blogs[get_current_blog_id()];

    That last bit of the object ‘blogs’ should be an array that looks something like this (illustrative only):

    array(
      '1' => 'aaa',
      '2' => 'bbb',
      '3' => 'ccc
    )

    If get_current_blog_id() is 1, 2, or 3 everything is fine. If it is 0, or greater than 3 you get that error. You are trying to access an array key that doesn’t exist. That is what ‘undefined offset’ means in this context. The code should check for the existence of that array key before trying to use it, as is done on the second line of the code you posted.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Error opening wp-admin’ is closed to new replies.