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:

    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.