comment_closed
Action HookDescription
Fires when a comment is attempted on a post that has comments closed.Hook Information
File Location |
wp-includes/comment.php
View on GitHub
|
Hook Type | Action |
Line Number | 3616 |
Hook Parameters
Type | Name | Description |
---|---|---|
int
|
$comment_post_id
|
Post ID. |
Usage Examples
Basic Usage
<?php
// Hook into comment_closed
add_action('comment_closed', 'my_custom_function', 10, 1);
function my_custom_function($comment_post_id) {
// Your custom code here
}
Source Code Context
wp-includes/comment.php:3616
- How this hook is used in WordPress core
<?php
3611 *
3612 * @since 1.5.0
3613 *
3614 * @param int $comment_post_id Post ID.
3615 */
3616 do_action( 'comment_closed', $comment_post_id );
3617
3618 return new WP_Error( 'comment_closed', __( 'Sorry, comments are closed for this item.' ), 403 );
3619
3620 } elseif ( 'trash' === $status ) {
3621
PHP Documentation
<?php
/**
* Fires when a comment is attempted on a post that has comments closed.
*
* @since 1.5.0
*
* @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.