Home › Forums › Front-end Issues › Edit Post Form sets comment_status OFF › Reply To: Edit Post Form sets comment_status OFF
Hi @adeon
I believe you’re using ACF free version. That means that you need to use extra functions to save the post. This page should give you more idea about it: https://www.advancedcustomfields.com/resources/using-acf_form-to-create-a-new-post/?version=4.
I’m not really sure why it changes the comment status, bu you can always use the acf/save_post
hook to change it back like this:
function my_acf_save_post( $post_id ) {
// Only do it for the front end form
if( is_admin() ){
return;
}
// set the comment status
$my_post = array(
'ID' => $post_id,
'comment_status' => 'open',
);
// remove action to avoid infinite loop issue
remove_action('acf/save_post', 'my_acf_save_post', 20);
// update the post
wp_update_post( $my_post );
// add the action back
add_action('acf/save_post', 'my_acf_save_post', 20);
}
// run after ACF saves the $_POST['acf'] data
add_action('acf/save_post', 'my_acf_save_post', 20);
I hope this helps 🙂
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.