Take the tour ×  I'm calling a custom function when someone
submits comments using the following to plug into the
comment_post action: add_action('comment_post', 'MY_FUNCTION');
The problem is that my function is extremely heavy, causing
about a 5 second delay between the time when someone submits a
comment to the time when the page refreshes and they view their
comment. Is there any way that my custom function could run in
the background, so that they could be redirected right away?
Alternatively, would it be safe to redirect them directly at the
top of my function, then run the rest of my function after they
had already been redirected?  share|improve this question add
comment  1 Answer  up vote 2 down vote accepted  If you're
sending a redirect, then you can also just close the connection
early and continue processing.  header("Content-Length: 0");
header("Connection: close"); do_something(); // continue
processing whatever, user is already redirecting by now
Reference: http://www.php.net/manual/en/featu