In the success part of your code, you can build an array representing a post, and use wp_insert_post as such :
Example
$mypost = array(
'post_title' => 'My Title',
'post_type' => 'page'
//... add other fields according to your form
);
$mypost_id = wp_insert_post( $mypost ); //Returns new post id on success
Any field you don’t specify will be filled by WordPress automatically.
EDIT
For custom fields, see add_post_meta :
$mypost_id = wp_insert_post( $mypost ); //SEE ABOVE
$meta_key = 'your-new-field-name';
$meta_value="your-form-value";
$unique = true; // or false
add_post_meta( $mypost_id, $meta_key, $value, $unique );
Source : wp_insert_post
Related Posts:
- Programmatically Creating Page using $wpdb and getting 404 error
- How to run wp_insert_post() & wpdb on the background?
- $wpdb->insert() doesnt work anymore
- duplicate entries in database while using save_post or wp_insert_post
- adding a log row log table, when the draft post publish
- $wpdb->get_row() only returns a single row?
- what is the way to see the currently executing query in wordpress?
- Fetch array with $wpdb
- $wpdb->last_error doesn’t show the query on error
- Inserting data into custom tables
- Theoretical Multi-Server WordPress Setup with Shared Users
- Change post status based on meta value
- Delete/replace img tags in post content for auto published posts [closed]
- What does wp_update_post() do that the $wpdb class does not?
- wpdb-> not adding prefix to custom table
- WordPress insert NOW() in TIMESTAMP column returns all zeros
- $wpdb prepare issue with mysql DATE_FORMAT
- How-To: wpdb Insert Record With Date
- How to pass NULL in where array for $wpdb->update
- Get random row from custom table
- store custom WP table names in a global variable
- I am not understandinhg $wpdb->prepare correctly
- How to save html and text in the database?
- XOR functionality for meta_query
- Using WPDB class
- How can I migrate mysql_fetch_array to $wbpdb?
- What is _transient_random_seed for?
- wpdb get_results() and prepare when to use prepare?
- Foreach loop using $wpdb not results from rows
- How to get a value-only flat array from $wpdb->get_results when selecting a single column, without foreach()?
- How to Instantiate wpdb Object in New File
- How do you build a wpdb query dynamically?
- Would this WPDB setup result in potential race conditions?
- How to update a row in a table in WordPress
- What’s the proper way to add users to my site in order to test things?
- Frontend Post with JQuery AJAX to Php Issue
- Optimizing WordPress Queries – Removing Group By ID
- External DB Connection [closed]
- Codex: Database Description: meaning of Cardinality
- Code only works every other time its run
- Can’t pass variable in wordpress wpdb->get_results
- WordPress db prepare
- How do I count columns on a custom WPDB query?
- how to get db values without using an loop with wpdb->get_results()
- Custom SQL query ORDER BY term_order
- Trouble inserting string containing quotations marks with wpdb in save_post hook
- Trying to get variable from WP table and toggle its value
- Set MySQL variables in WPDB
- get_results query with accent
- How to prepare an array of values with $wpdb
- Is querying wpdb directly and skipping actions provided by WP’s core “wp_update_post” a good idea?
- $wpdb query outputs php code instead of executing it
- wpdb query not working
- Where can I see MySQL hostname and port for wp-config.php
- WordPress wpdb->insert returns int(0) => doesn’t insert anything, no errors!
- Using “->” in a page to exceute $wpdb query gives error
- Exclude specific terms from all queries using posts_where or something similar
- $wpdb->get_results not returning an array
- Insert two row in wordpress database
- query a newly created table using $wpdb
- Get all sticky posts from one user through user ID
- WPDB Query Question with Category Only
- wpdb result arrray inside an array
- $wpdb->num_rows doesn’t work
- How can I change my meta_query to SQL wpdb query?
- How capturate wpdb exceptions?
- Limit left join
- “This message was added in version X” showing a later version than current one
- Get records from Formidable Table using $wpdb->get_col
- Prepare WPDB with meta key and meta value
- How to get row value from wpdb
- I am using wpdb but it not working perfectly.but if I dont use form data its work
- Insert user register into my own user table instead of wp own user
- wont add form details to database or send me mail
- Submitting custom post from frontend,jQuery ajax, and custom validation – can’t find proper place to insert wp_insert_post()
- Call to a member function insert()
- Missing argument 2 for wpdb::prepare() [duplicate]
- wpdb->update update the entire table instead of one row
- WPDP related functions look to work but they don’t
- Save customizer default values to DB on theme activation
- Plugin with connection to database – Single function
- Alter the main search query to search posts by coauthor user name
- Ajax Form data is not posted back to the get_results()
- Protect custom form from SQL injection
- why nl2br() is adding an extra ?
- How to add more custom fields in user meta table simultaneously
- wpdb->update error
- get unserialized array without using get_option()
- SQL Query to select post title & post ID from a particular category
- Create Table Failed Column Date DateType
- Using $wpdb to update current post
- Checking if meta_value exists for any user
- Can you create a new wpdb that connects to an SQL (not MYSQL) database? [duplicate]
- DBDelta: “table doesn’t exist” for a table that was just created
- upload images on front by user using form
- query using wpdb in wordpress gets me no result
- $wpdb The query does not contain the correct number of placeholders
- How to redirect to a page after submitting form data?
- $wpdb:insert, more arguements in $format array than in $data
- Putting form result in my database