Does anyone know why this ‘comment_post’ hook doesn’t seem to work!?
…
When a comment is posted, the function is not triggered… at all?
The hook works. Try the following, it works:
add_action( 'comment_post', 'test_notify' );
function test_notify($args , $args2) {
echo 'It works!';
die;
}
As does this:
add_action( 'comment_post', 'test_notify' );
function test_notify($args , $args2) {
echo 'It works!';
header("Location: http://www.google.com");
die;
}
This, in fact, works also but you are likely to get a 404:
add_action( 'comment_post', 'test_notify' );
function test_notify($args , $args2) {
echo 'It works!';
header("Location: /blog?thisworked=true");
die;
}
You want to be using site_url()
or home_url()
probably:
add_action( 'comment_post', 'test_notify' );
function test_notify($args , $args2) {
echo 'It works!';
header('Location: '.home_url('/blog?thisworked=true'));
die;
}
If those don’t work, something is interfering and I don’t know how to guess what.