How to catch wordpress post ID when it’s published

To put it briefly, WordPress hooks let you modify parameters or output of functions (filters) or execute custom code when something happens (actions). Both types of hooks usually pass one or more arguments to the callback functions that are attached to them. During a page request WordPress goes through series of steps to get the … Read more

WordPress action – Pass arguments into action in an AJAX call?

You can’t pass arguments to wp_ajax_ callbacks. You need to pass the data via the data property of the AJAX request. Then you get those values with $_POST and pass them to a function: function newsletterSignupAjax() { $id = $_POST[‘id’]; $source = $_POST[‘source’]; /* Make sure to validate and sanitize those values. */ newsletterSignup( $id, … Read more

Are there action hooks for comments?

In WordPress, almost anything is possible. It all depends at times how hard you want to work for it. 🙂 The Comment Post form of course uses HTTP POST to submit to /wp-comments-post.php so you could use that except for the NONCEs if you want to post unfiltered HTML. You’d have to write a page … Read more

comment_post callback function: how to run it in the background.

If you’re sending a redirect, then you can also just close the connection early and continue processing. wp_safe_redirect(‘http://example.com’); header(“Content-Length: 0”); header(“Connection: close”); flush(); do_something(); // continue processing whatever, user is already redirecting by now Reference: http://www.php.net/manual/en/features.connection-handling.php#104541 Read those user comments carefully, there’s some caveats there.