Home › Forums › Front-end Issues › Frontend Edit & Create Posts › Reply To: Frontend Edit & Create Posts
Hi,
Thanks for your reply, i managed to make it work however i have an issue with a few fields.
The create new post form, successfully creates the listing and i’m also grabbing the post title and the post content and the featured image through custom fields. This works.
I have then attempted to modify the action so instead of inserting a new post, he would update it. The edit works but some of the fields are not updating. For example when i modify the post and i attempt to modify the custom field that has been used for the post title, it isn’t updating the post title but just the custom field.
This is part of the code used.
global $current_user;
// check if this is to be a new post
if( $post_id != 'new_listing' )
{
return $post_id;
}
// Create a new post
$post = array(
'post_status' => get_field('default_listing_submission_status','option') ,
'post_title' => $_POST["fields"]['field_522f30035c85b'],
'post_content' => $_POST["fields"]['field_5230848453094'],
'post_type' => 'listing' ,
);
$post_edit = array(
'post_status' => get_field('default_listing_submission_status','option') ,
'post_title' => 'test',
'post_content' => 'test2',
'post_type' => 'listing' ,
);
//add listing
if( $post_id = 'new_listing' ) {
$post_id = wp_insert_post( $post );
} else {
$post_id = wp_update_post( $post_edit );
}
Do you have any idea why the form wouldn’t update the post title or the content ?
Thank you. If needed i can post the whole code but i don’t anything else in the action is interfering with it.
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.