• Hello all,

    I’m developing a plugin which makes use of the wp_redirect function. You can see the relevant code here:

    However, when I try to run that code I get this error.

    Cannot modify header information – headers already sent by (output started at /path/to.site/wp-includes/query.php:390) in /path/to/site/wp-content/plugins/post_shock/postshock_core.php on line 53

    Now, I checked query.php and nothing on line 390 seems to be creating any whitespace or sending any header info at all, so I suspect the problem might be deeper. Any ideas or thoughts would be appreciated!

Viewing 3 replies - 1 through 3 (of 3 total)
  • I’d expect that an error is being thrown somewhere, hence causing the problem. Are you running with wp_debug enabled?

    Thread Starter AphelionZ

    (@aphelionz)

    Yeah, it’s all notices and warnings based on some other plugins BUT that warning is one of them.

    Thread Starter AphelionZ

    (@aphelionz)

    I got it running now with no warnings, but it still doesn’t redirect for some reason – and its not calling any errors! Here’s the code in question:

    add_action('init', 'search_egg_redirect', 0);
    
    function search_egg_redirect() {
    	global $wpdb;
    	$query = $wpdb->prepare($_GET['s']);
    
    	if(!empty($query)) {
    		$term_row = $wpdb->get_row('SELECT term,page_id FROM pshock_searcheggs WHERE TERM="' . $query . '" LIMIT 1');
    		if($term_row->term) {
    			wp_redirect('https://google.com');
    		}
    	}
    }
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Cannot Modify Headers – wp-includes/query.php:390’ is closed to new replies.