admin管理员组

文章数量:1334380

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

本文标签: Update post quotAquot on comment submition on post quotBquot