comment_on_draft
Action HookDescription
Fires when a comment is attempted on a post in draft mode.Hook Information
File Location |
wp-includes/comment.php
View on GitHub
|
Hook Type | Action |
Line Number | 3642 |
Hook Parameters
Type | Name | Description |
---|---|---|
int
|
$comment_post_id
|
Post ID. |
Usage Examples
Basic Usage
<?php
// Hook into comment_on_draft
add_action('comment_on_draft', 'my_custom_function', 10, 1);
function my_custom_function($comment_post_id) {
// Your custom code here
}
Source Code Context
wp-includes/comment.php:3642
- How this hook is used in WordPress core
<?php
3637 *
3638 * @since 1.5.1
3639 *
3640 * @param int $comment_post_id Post ID.
3641 */
3642 do_action( 'comment_on_draft', $comment_post_id );
3643
3644 if ( current_user_can( 'read_post', $comment_post_id ) ) {
3645 return new WP_Error( 'comment_on_draft', __( 'Sorry, comments are not allowed for this item.' ), 403 );
3646 } else {
3647 return new WP_Error( 'comment_on_draft' );
PHP Documentation
<?php
/**
* Fires when a comment is attempted on a post in draft mode.
*
* @since 1.5.1
*
* @param int $comment_post_id Post ID.
*/
Quick Info
- Hook Type: Action
- Parameters: 1
- File: wp-includes/comment.php
Related Hooks
Related hooks will be displayed here in future updates.