2016-06-10 97 views

回答

2

如果你只是想改變到期日,你可以使用comment_cookie_lifetime過濾器。

E.g.兩年後到期的:

add_filter('comment_cookie_lifetime', 2*YEAR_IN_SECONDS); 

把它改成會話,你需要從set_comment_cookies鉤刪除默認wp_set_comment_cookies並添加自己的一個設置會話cookie。

實施例:

remove_action('set_comment_cookies', 'wp_set_comment_cookies', 10, 2); 

add_action('set_comment_cookies', function(\WP_Comment $comment, \WP_User $user) 
{ 
    // set session 
}, 10, 2);