• Hi there,

    I’m getting a headers sent error when I save the settings page in WordPress.

    Warning: Cannot modify header information – headers already sent by (output started at /var/sites/urlexample/public_html/wp-content/plugins/post-types-order/include/class.options.php:40) in /var/sites/urlexample/public_html/wp-admin/includes/misc.php on line 1114

    I’ve had a look at the class.options file in a code editor and the closing PHP tag isn’t highlighted as a closed tag if that makes sense. It’s not highlighted as a clean white closing tag so wondering if there’s a syntax issue? Any help would be much appreciated. Also I have the issue with Yoast SEO making the reordering difficult!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Looks an echo in class.options.php on line 40 is causing this issue. It should be used as an notification to notify the user that the settings have been saved.

    Because of this echo, content is being sent to the client and therefor the headers can no longer be sent.

    Plugin Author Maya

    (@tdgu)

    Hi,
    I’am not sure why this issue might occur for you, as the admin dashboard use output buffering anyway, so the headers can be pushed. Also there should be other html data in place, before this message output, so it shouldn’t make any difference.

    Possible the warning is showing up in conjunction with another plugin? Also which php version you use?

    Thanks

    I realize this topic is 7 months old but I’m having the same issue. I’ve disabled all plugins and have tried both PHP 5.6.21 and 7.0.6 and am still having the same result.

    Here are the errors I’m receiving:

    Warning: Cannot modify header information - headers already sent by (output started at /domain-path/html/wp-content/plugins/post-types-order/include/class.options.php:40) in /domain-path/html/wp-admin/includes/misc.php on line 1126
    
    Warning: Cannot modify header information - headers already sent by (output started at domain-path/html/wp-content/plugins/post-types-order/include/class.options.php:40) in /domain-path/html/wp-includes/option.php on line 919
    
    Warning: Cannot modify header information - headers already sent by (output started at /domain-path/html/wp-content/plugins/post-types-order/include/class.options.php:40) in /domain-path/html/wp-includes/option.php on line 920
    Plugin Author Maya

    (@tdgu)

    @thepeel can you ask for more help at http://www.nsp-code.com ?

    I get exactly the same error at line 40 when saving settings.

    I just got a fix for this.

    By replacing

    echo '<div class="updated fade"><p>' . esc_html__('Settings Saved', 'post-types-order') . '</p></div>'; (line #40)

    with the following

    add_action('admin_head', function(){
       echo '<div class="updated fade"><p>' . esc_html__('Settings Saved', 'post-types-order') . '</p></div>';
    }, PHP_INT_MAX);

    PHP_INT_MAX will make sure that printing message gets the lowest priority.

    @tdgu it would be great if you please review it once.

    Thank you!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Warning: Cannot modify header information error when saving settings’ is closed to new replies.