I modified the file wp-comments-post.php by adding this in there:

setcookie('addcomment', $_SERVER['HTTP_REFERER'], (time()+300), "/");

After 54 lines, in the end it became like this.

...nsent Comment author's consent to store cookies.
setcookie('addcomment', $_SERVER['HTTP_REFERER'], (time()+300), "/");
do_action( 'set_comment_cookies', $comment, $user, $cookies_consent );

$location = empt...

How to do the same using functions.php?

Sorry for my English. Please help me.

  • 1
    imediatley after your code is an action/hook, have you tried using that instead?
    – Tom J Nowell
    Oct 6, 2021 at 8:51


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.