admin管理员组文章数量:1328037
I am developing 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.
I am developing 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.
Share Improve this question edited Jul 22, 2020 at 11:16 cjbj 15k16 gold badges42 silver badges89 bronze badges asked Jul 22, 2020 at 11:02 Álvaro FranzÁlvaro Franz 1,1001 gold badge9 silver badges31 bronze badges1 Answer
Reset to default 1As you can see from the source code, wp_redirect
always ends in a PHP header request, except if the location is empty, because then it doesn't know where to redirect. So you can indeed use the wp_redirect
filter. If you return an empty string under certain circumstances, the redirect will not happen.
本文标签: Filter wpredirect() to stop redirect under certain condition
版权声明:本文标题:Filter wp_redirect() to stop redirect under certain condition 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742242143a2438899.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论