Hi, how can I let change a post status in front end? I have this shortcode but change only the value in the entries not in wordpress post
[frm-entry-update-field id=[id] field_id=10 value='Published' label="Publish" class="reload_page"][/if 10]
See this: https://developer.wordpress.org/reference/functions/wp_update_post/
but how can I pass the post id ?
add_action('frm_after_update_entry', 'update_post_statusr', 10, 2);
function update_post_statusr($entry_id, $form_id){
if ( $form_id == 2 ) {
$postid = $_POST['item_meta'][?];//
$status = $_POST['item_meta'][10];//
$my_post = array(
'ID' => $postid,
'post_status' => $status,
);
wp_update_post( $my_post );
}
}
You need to retrieve the post ID from the entry or examine the contents of the PHP $_POST associative array to see if its available there.
Please login or Register to submit your answer