• Hi there,

    I keep getting the error Warning: Cannot modify header information – headers already sent by ERROR while trying to modify some aspects of my WordPress website.

    My PHP skills aren’t amazing so I am not entirely sure what’s going wrong 🙁

    This is the complete error message:

    Notice: Undefined index: woo_nonce in /customers/6/7/e/katzenworld.uk/httpd.www/shop/wp-content/themes/mystile/functions/classes/class-wf-meta.php on line 149 Warning: Cannot modify header information - headers already sent by (output started at /customers/6/7/e/katzenworld.uk/httpd.www/shop/wp-content/themes/mystile/functions/classes/class-wf-meta.php:149) in /customers/6/7/e/katzenworld.uk/httpd.www/shop/wp-includes/pluggable.php on line 1196

    I have had a look at line 149 in the first mentioned file:

    if ( ! wp_verify_nonce( $_POST[$this->_field_obj->__get( 'token' ) . '_nonce'], $this->_field_obj->__get( 'token' ) . '_nonce' ) ) {

    And also the line 1196 in the second file:

    header("Location: $location", true, $status);

    I checked that there are no random spaces at the end or the beginning of the PHP file.

    Any help wiuld be much appreciated.

    Thanks,

    Marc

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hey Marc,

    Please check two points:
    1. There must not be _blank pages_ and _spaces_ before the first line <?php and the last line ?>
    Better check it with some editor which supports non-printable characters(for example Notepad ++);
    2. Use editor mentioned above for saving(transforming) your file to UTF-8 without BOM.
    Please let me know the results then.

    Best regards,
    Eugene

    Thread Starter Medran

    (@medran)

    Hi Eugene,

    I couldn’t find a space with notepad++ and it was already in UTF-8 without BOM what I did notice is that the first file doesn’t have a ?> the last line ends on endif; would that maybe cause the issue?

    Thanks,

    Marc

    Hi Medran,

    I’ve stumbled upon probably the same issue on WooCommerce GitHub pages. The “solution” proposed there is to turn off WP_DEBUG, so PHP notices won’t show. However, I can see you are getting a PHP Warning. It is being reported to come from the same line so maybe these two problems are connected somehow.

    The message about the pluggable.php file is just that the headers have already been sent from the function wp_redirect. The problem definitely doesn’t lie there as it’s a WordPress Core function.

    Thread Starter Medran

    (@medran)

    Oh. That got rid of the annoying notice whenever I make an amendment… So I guess as long as it’s nothing critical I can live with it in this way.

    Cool. Yes, you can but when you have some free time, I recommend trying to fix the issue as they might accumulate and cause bigger troubles in the future.

    Good luck

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

The topic ‘Warning: Cannot modify header information – headers already sent by ERROR’ is closed to new replies.