WordPress Development Asked by A. Hartzet on December 3, 2021
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.com/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
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP