Post status after frontend editing

By: Roberta Cerami | Asked: 04/15/2024
ForumsCategory: General questionsPost status after frontend editing
Roberta Cerami asked 1 month ago
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] 
1 Answers
Victor Font answered 1 month ago
See this: https://developer.wordpress.org/reference/functions/wp_update_post/
Roberta Cerami replied 1 month ago

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 );

}
}

Victor Font replied 1 month ago

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.

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right