最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Update post "A" on comment submition on post "B"

programmeradmin6浏览0评论

Hello and thanks in advance for any help. Im trying to update the post status from a post when submiting a comment on other post, I have a variable in the url pointing to the ID of the post I want to update like so mysite/some-post/?id=1234

Hooking into 'comment_post' wont get the variable, so a new post is created insted of updating

add_action( 'comment_post', 'aa_comment_update_post' );

function aa_comment_update_post( $comment_ID ) {

   $id = $_GET['id'];

   $postarr = array(
      'ID'            => $id,
      'post_status'   => 'draft',
   );

  wp_update_post( $postarr );

}

Any idea would be much appreciated

发布评论

评论列表(0)

  1. 暂无评论