Filter wp_redirect() to stop redirect under certain condition


I am developping a tool to print PHP debug messages on screen.

I would like to stop the wp_redirect() function from actually doing the redirect if the debug tool contains a message that it wants to display.

One way would be to check this before calling wp_redirect() at all, but it’s preferable to have something like a before_redirect filter where I can decide to “go on” or “don’t go”.

I have seen the wp_redirect filter allows me to filter the redirect location.

I could say “go back to the same place” but that would be a new http request and the logs would be already lost.

, , Alvaro Franz 1 year 2020-07-22T06:10:21-05:00 0 Answers 45 views 0

Leave an answer