• Hi

    I’ve add a custom form to my front end of a twentyten theme. which creates a custom post type beautifully for me. but what if I want to add details to the post once its formed? is there a way to update custom fields on a post in the front end?

Viewing 1 replies (of 1 total)
  • Thread Starter broadleon

    (@broadleon)

    Currently trying this but the custom field is not updating

    if( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) && $_POST['post_type'] == 'log' ) {
    
    // ADD THE FORM INPUT TO $new_post ARRAY
    	$new_post = array(
    	'post_title'	=>	$title,
    	'post_content'	=>	$description,
    	'post_category'	=>	array($_POST['cat']),  // Usable for custom taxonomies too
    	'tags_input'	=>	array($tags),
    	'post_status'	=>	'publish',           // Choose: publish, preview, future, draft, etc.
    	'post_type'	=>	'log',
    	);
    
    wp_insert_post($post);
    
    if($pid)
    {
    update_post_meta($pid, "complete", sanitize_text_field( $_POST['complete'] ) );
    }
    
    } 
    
    do_action('wp_insert_post', 'wp_insert_post');
    
    ?>
    
    	<form id="new_post" name="new_post" method="post" action="" class="wpcf7-form" enctype="multipart/form-data">
    	<!-- complete Date -->
    			<fieldset class="complete">
    				<label for="complete">complete Date:</label>
    				<input type="text" id="complete" value="" tabindex="5" name="complete" />
    			</fieldset>
    			<fieldset class="submit">
    				<input type="submit" value="publish" tabindex="40" id="submit" name="submit" />
    			</fieldset>
    </form>

Viewing 1 replies (of 1 total)
  • The topic ‘update custom fields with new information’ is closed to new replies.