WordPress.org

Ready to get started?Download WordPress

Forums

Google Content Experiments
Error When Viewing Pages with Experiment Code (3 posts)

  1. optimized-marketing.com
    Member
    Posted 1 year ago #

    I have multiples sites that I use this plug-in with. It doesn't seem to be happening on all pages. My sites are set up to not use www. at the beginning. If you put http://www.mysite.com it actually goes to mysite.com with no issues.

    But when I have a page with the Google Content Experiment option checked and I try to go to http://www.mysite.com/Experimentpage/ it doesnt redirect to mysite.com/Experimentpage/ as it should it throws the following error.

    "Warning: Cannot modify header information - headers already sent by (output started at /home/bob/public_html/mysite.com/wp-content/plugins/google-content-experiments/class-wpe-GCE.php:42) in /home/bob/public_html/mysite.com/wp-includes/pluggable.php on line 881"

    Let me know if you need more information
    Thanks
    Greg

    http://wordpress.org/extend/plugins/google-content-experiments/

  2. glennm
    Member
    Plugin Author

    Posted 1 year ago #

    On wp-includes/pluggable.php (line 881) the wp_redirect is performed:
    header("Location: $location", true, $status);

    Apparently there already is some output before wp_redirect is executed. I don't know if this is the most beautiful option and if it will work, but let's try this:
    In google-content-experiments.php:

    • Place ob_start(); between */ and if ( !defined('WPE_GCE_PATH') )
    • Place ob_end_flush(); right before the closing ?>
  3. optimized-marketing.com
    Member
    Posted 1 year ago #

    I added your suggested code but that just gave the same error.

    I got it working another way by still using the ob_start(); but I had to added it to the function.php file.

    The code I added to Function.php

    //allow redirection, even if my theme starts to send output to the browser
    add_action('init', 'do_output_buffer');
    function do_output_buffer() {
    ob_start();
    }

    After I verified this would work. I decided to go back and test your suggestion again. I added ob_start() and ob_end_flush(). Same error so I figured I would just try ob_start() at the begining of google-content-experiments.php and not add ob_end_flush();

    Adding only ob_start() to google-content-experiments.php actually fixed the problem. I am not sure what ob_start(); does or if not including ob_end_flush(); would have any negative impact.

    Let me know if you think this is a valid approach or not.
    Thanks
    Greg

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.