【发布时间】:2012-09-03 21:06:35
【问题描述】:
我正在尝试在访问者提交评论时设置自定义 cookie,但我似乎无法正常工作。这是我在functions.php中的内容:
add_action('comment_post', 'ipro_set_comment_cookie');
function ipro_set_comment_cookie($comment) {
setcookie("visitor_name", $comment->comment_author, time()+86400);
setcookie("visitor_email", $comment->comment_author_email, time()+86400);
}
我也尝试将comment_post 更改为wp_insert_comment - 似乎都没有工作。我正在研究 WP 的动作参考:
http://codex.wordpress.org/Plugin_API/Action_Reference#Comment.2C_Ping.2C_and_Trackback_Actions
...有什么想法吗?
【问题讨论】:
-
我相信你正在寻找这个:stackoverflow.com/questions/5759882/…
标签: php wordpress cookies setcookie