In asking a question about hooks and redirects, I was advised to use wp_redirect in place of the PHP header function. Just wondering why wp_redirect is preferable?
Leave a Reply
You must be logged in to post a comment.
In asking a question about hooks and redirects, I was advised to use wp_redirect in place of the PHP header function. Just wondering why wp_redirect is preferable?
You must be logged in to post a comment.
See the source. It has some additional logic for IIS servers, as well as some hooks. It is also pluggable function, so it might be redefined.
Overall it’s just more flexible and gives other developers more options to work with your code, unavailable if you just hardcode things.
It (wp_redirect fn) is more than just setting the header. Just take a look here what it does before setting a header.