0

in wordpress version 3.6 and 3.7 everything works great, but with version 4 and above I get:

Cannot modify header information - headers already sent

the problem line is:

header('Location: '. $redirect 

Is there some security script in the new version?

How can i override it?

  • Which file is the "problem line" in? – TheDeadMedic May 15 '15 at 10:56
  • the file is in the plugin directory – DrMosko May 15 '15 at 12:38
  • 1
    But which file? – TheDeadMedic May 15 '15 at 12:48
1

Use wp_redirect() function instead of header().

Here is the code example:

wp_redirect($redirect);
|improve this answer|||||
  • when i use this same problem but now its not my plugin, its wordpress core: /home/work/public_html/wp-includes/pluggable.php on line 1196 – DrMosko May 15 '15 at 13:32
  • 1
    The problem here is that you have gotten some text or whitespace (spaces, newline) before the opening PHP tag or after the closing PHP tag in your theme's functions.php file. There can't be a single character before or after those tags. – mukto90 May 15 '15 at 16:13
  • so, why it worked in earlier wordpress versions? – DrMosko May 17 '15 at 3:41
  • @DrMosko plenty have changed between 3.7 and 4.0 and many bugs was rectified and new features added. That is why it is important to keep your code up to date with core and php version changes. Your plugin is getting behind and becoming a security risk for those who are using it. Find the bug and fix it – Pieter Goosen Jun 4 '15 at 7:54
  • how do i use wp_redirect() to create onfly page, with get parameters? – DrMosko Jun 7 '15 at 1:26
0

Probably a plugin conflict. Rename your plugin folder to disable all plugins and see if the problem still persists. If the proplem is gone reactivate the plugins one by one to see which one is causing the problem.

|improve this answer|||||
  • thx, but its not a plugin conflict – DrMosko May 15 '15 at 12:37
-1

I dont know whats wrong with the new wordpress version, but somthing has changed, and my plugin hasnt, but i was able to sort it out with ob_start()

|improve this answer|||||
  • If output buffer fixed it then certainly there was some kind of output before headers were sent to begin with. Using output buffer is great, but if it's only purpose is to fix a bug and not to actually buffer any output then you are using it wrong and would be better served by finding the actual output causing the error. – KnightHawk Jun 4 '15 at 4:14
  • You are simply just hiding the error, not resolving/fixing it. This method is not recommended. Buffering should never be your first go-to, but your absolute last. Find the error and fix the error, never hide it. A hidden error is not debuggable and extremely hard to find later on. Spare yourself that headaches and sleepless nights :-) – Pieter Goosen Jun 4 '15 at 7:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.