Home › Forums › Front-end Issues › Frontend Edit & Create Posts › Reply To: Frontend Edit & Create Posts
Hi @alexgold05
I can see at the top of your code that if the $post_id != ‘new_listing’, you return the $post_id.
This return
will stop any further code from working!
Perhaps you need to change your code to look more like this:
<?php
global $current_user;
// check if this is to be a new post
if( $post_id == 'new_listing' )
{
// 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_id = wp_insert_post( $post );
}
return $post_id;
?>
I have taken the liberty of removing the update_post functionality as I don’t see how it does anything useful for the above code.
Thanks
E
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.