Title: Saving form data as posts
Last modified: November 23, 2017

---

# Saving form data as posts

 *  [sgeordien](https://wordpress.org/support/users/sgeordien/)
 * (@sgeordien)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/saving-form-data-as-posts/)
 * Hi
 * I’m building a custom contact form and need to establish the best practice for
   saving data.
 * Currently I’m creating a custom post type and mapping the form fields submitted
   to the fields within the post type. The post type is private (so no data publicly
   visible) but as much as its easy to create and manage in the admin I’m unsure
   whether this is the ‘done thing’. Any experienced advice would be greatly received.
 * Many thanks
    Steve

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [Subrata Sarkar](https://wordpress.org/support/users/subrataemfluence/)
 * (@subrataemfluence)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/saving-form-data-as-posts/#post-9713881)
 * Hi,
    Let me try to understand in own words.
 * 1. You are building a Custom Contact Form by the help of a Custom Post Type –
   Which is fine. It will be able to accept the information and save into `wp_posts`
   and `wp_postmeta` tables. You need to tell WordPress what will go into `wp_postmeta`
   table.
 * 2. You have probably already created the meta boxes. If yes, you will be able
   to show and edit them in admin as well. From user end, you just need to use a
   Form. Use `save_posts_your_post_type()` to save basic post type fields in `wp_posts`
   table like title, excerpt etc and rest of the fields to `wp_postmeta` table using`
   upate_post_meta($post_id , 'meta_field_name', $meta_value);`. The function `update_post_meta`
   first checks whether any the meta exists for the $post_id. If not it calls `add_post_meta`
   automatically.
 * 3. In admin edit (your post type) you need to call the metaboxes to display the
   controls with their values prepopulated.
 * I am not very sure though if I could address exactly what you actually want to
   accomplish!
 *  Thread Starter [sgeordien](https://wordpress.org/support/users/sgeordien/)
 * (@sgeordien)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/saving-form-data-as-posts/#post-9717443)
 * Hi Subrata
 * Thanks for the informative reply. I think my main concern was whether saving 
   contact form data as a post rather than to a custom table was the right thing
   to do. It seems like a good way to manage contact enquiries but would rather 
   do it the correct way.
 * Many thanks
    Steve

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Saving form data as posts’ is closed to new replies.

## Tags

 * [forms](https://wordpress.org/support/topic-tag/forms/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [sgeordien](https://wordpress.org/support/users/sgeordien/)
 * Last activity: [8 years, 4 months ago](https://wordpress.org/support/topic/saving-form-data-as-posts/#post-9717443)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
