Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am attempting to create a form that submits data and creates a post with custom fields filled. What I would like to do in step form.

1) Create a custom posttype function called "pickups" (I do not know how to do this)

2) Inside Pickups I need a function to created 5 separate columns which will be populated from the post types custom field.

3) Build a Form that will populate those 5 columns as a new postype(not sure if that is the correct term)

4) Then I need to output this data I am assuming with short code to a page.

Here is some code I have found, however parts of it will need to be modified and the postype function will still need to be built.

pickup.php

<!-- New Post Form -->

<div id="postbox">
<form id="new_post" name="new_post" method="post" action="">
<p><label for="name">Name</label><br />
<input type="text" id="name" value="" tabindex="1" size="20" name="name" />
</p>
<p><label for="address">Address</label><br />
<input type="text" id="address" value="" tabindex="1" size="20" name="address" />
</p>
<p><label for="Phone">Phone</label><br />
<input type="text" id="Phone" value="" tabindex="1" size="20" name="Phone" />
</p>
<?php wp_nonce_field( 'new-post' ); //Apparently needed for security ?> 
</form>
</div><!--postbox ends-->

<?
if( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] )) {

    // Do some minor form validation to make sure there is content
    if (isset ($_POST['name'])) {
        $name =  $_POST['name'];
    } else {
        echo 'Please enter a name';
    }
    // Repeat this for each input field


    // Add the content of the form to $post as an array
    $post = array(
        'post_name' => $name,
        'post_address'  => $address,
        'post_phone'    => $phone,

    );
    wp_insert_post($post);  // Pass  the value of $post to WordPress the insert function
                            // http://codex.wordpress.org/Function_Reference/wp_insert_post
    wp_redirect( home_url() );
} // end IF

// Do the wp_insert_post action to insert it
do_action('wp_insert_post', 'wp_insert_post'); 

?>

<!--// New Post Form -->
share|improve this question
add comment

1 Answer

http://wpshout.com/wordpress-submit-posts-from-frontend/

Refer above link, we can check user logged in or not in fronted and pass custom post type too while saving post in database.

share|improve this answer
    
this doesn't have anything about making the custom-postype this just shows how to add to a regular post –  Anders Kitson Jan 25 '12 at 6:09
    
@AndersKitson please read all tutorial , before calling wp_insert_post($post); in $post array you can pass 'post_type' whatever you want ie your custom post type. Its explained there well. –  amolv Jan 25 '12 at 6:14
    
I have read the whole tutorial, I am still trying to figure out how to create columns in a custom post-type. –  Anders Kitson Jan 25 '12 at 6:24
    
@AndersKitson what you mean 'create columns in a custom post-type.'? –  amolv Jan 25 '12 at 6:48
    
something like this, wordpress.stackexchange.com/questions/28413/… –  Anders Kitson Jan 25 '12 at 6:56
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.