set_comment_cookies
Action HookDescription
Fires after comment cookies are set.Hook Information
File Location |
wp-comments-post.php
View on GitHub
|
Hook Type | Action |
Line Number | 55 |
Hook Parameters
Type | Name | Description |
---|---|---|
WP_Comment
|
$comment
|
Comment object. |
WP_User
|
$user
|
Comment author's user object. The user may not exist. |
bool
|
$cookies_consent
|
Comment author's consent to store cookies. |
Usage Examples
Basic Usage
<?php
// Hook into set_comment_cookies
add_action('set_comment_cookies', 'my_custom_function', 10, 3);
function my_custom_function($comment, $user, $cookies_consent) {
// Your custom code here
}
Source Code Context
wp-comments-post.php:55
- How this hook is used in WordPress core
<?php
50 *
51 * @param WP_Comment $comment Comment object.
52 * @param WP_User $user Comment author's user object. The user may not exist.
53 * @param bool $cookies_consent Comment author's consent to store cookies.
54 */
55 do_action( 'set_comment_cookies', $comment, $user, $cookies_consent );
56
57 $location = empty( $_POST['redirect_to'] ) ? get_comment_link( $comment ) : $_POST['redirect_to'] . '#comment-' . $comment->comment_ID;
58
59 // If user didn't consent to cookies, add specific query arguments to display the awaiting moderation message.
60 if ( ! $cookies_consent && 'unapproved' === wp_get_comment_status( $comment ) && ! empty( $comment->comment_author_email ) ) {
PHP Documentation
<?php
/**
* Fires after comment cookies are set.
*
* @since 3.4.0
* @since 4.9.6 The `$cookies_consent` parameter was added.
*
* @param WP_Comment $comment Comment object.
* @param WP_User $user Comment author's user object. The user may not exist.
* @param bool $cookies_consent Comment author's consent to store cookies.
*/
Quick Info
- Hook Type: Action
- Parameters: 3
- File: wp-comments-post.php
Related Hooks
Related hooks will be displayed here in future updates.