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.

A unique wp_schedule_single_event() for each post?

You can pass arguments to the wp_schedule_single_event function: wp_schedule_single_event($newdate, “one_day_before_event”, array($post->ID)); Then if you do an add_action you can say how many arguments it will receive (in this case 1). add_action( ‘one_day_before_event’, ‘some_function’, 10, 1 ); Then in your function you can access the variable: function some_function($post_id) { // Do something with $post_id }