It doesn't work with comment_post
i have tested the hook add_action('publish_<my_custom_type_name>' and it works but comment_< my_custom_type_name > doesn't work.
Can you tell me what I have to use ?
When i insert this code :
add_action('publish_fichier', 'call_the_endpoint',10,2);
function call_the_endpoint($post_id, $post){
Content of my function it works
}
Then I have tried with the comment I have tried whith
add_action('comment_fichier', 'test_function',10,2);
and
add_action('comment_post', 'test_function',10,2);
It doesn't work
Hi, Shane is on public holiday today so I'll try to help. The comment_post hook should work with custom post types, so I suspect something else is going on. Please try these troubleshooting steps first:
- Temporarily deactivate all plugins except Types and Views
- Submit the comment form on the CPT post. If the problem was resolved, activate your other plugins one by one until the problem returns.
- If the problem does not seem to be resolved, please turn on server logs and add error logging to this callback like this:
function test_function( $post_id, $post ) {
error_log('comment posted for post ' . $post_id);
// your code continues below this line...
// ...
}
add_action('comment_post', 'test_function',10,2);
If you're not familiar with server logs, I can show you how to activate them temporarily. Go in your wp-config.php file and look for define(‘WP_DEBUG’, false);. Change it to:
define('WP_DEBUG', true);
Then add these lines, just before it says 'stop editing here':
Submit a Comment, and you should find an error_log.txt file in your site's root directory. Please send me its contents. Once that is done, you can revert the changes you made to wp-config.php.