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 have a custom script that allows to add per form submit to add contacts to a custom post type. But for some reason it always adds the data to the posts instead into the post type.

i have tried everything so far but no luck here is the code for the form i took out the form verification out since that part is working

        if( !isset( $hasError ) ) {

        $submit_to_contact_manager = array(
            'post_title' => 'Request from '. esc_attr(strip_tags($_POST['request_lastname'])),
            'post-type' => 'tpf_cnm',
            'post_status' => 'pending'
        );

        $contactmanager_id = wp_insert_post($submit_to_contact_manager);

        if($contactmanager_id)
        {

            // Update Custom Meta
            update_post_meta($contactmanager_id, 'tpf_first_name_preorders', esc_attr(strip_tags($_POST['request_firstname'])));
            update_post_meta($contactmanager_id, 'tpf_last_name_preorders', esc_attr(strip_tags($_POST['request_lastname'])));
            update_post_meta($contactmanager_id, 'tpf_email_preorders', esc_attr(strip_tags($_POST['request_email'])));
            update_post_meta($contactmanager_id, 'tpf_preorder_desc', esc_attr(strip_tags($_POST['request_message'])));
            update_post_meta($contactmanager_id, 'tpf_preorder_desc', esc_attr(strip_tags($_POST['request_category'])));


        }
    }

and here is the post type function

        add_action('init', 'tpf_cnm_init');

    function tpf_cnm_init(){

    $tpf_cnm_type_labels = array(
    'name' => _x('Contacts', 'post type general name'),
    'singular_name' => _x('Contact', 'post type singular name'),
    'add_new' => _x('Add New Contact', 'image'),
    'add_new_item' => __('Add New Contact'),
    'edit_item' => __('Edit Contact'),
    'new_item' => __('Add Contact'),
    'all_items' => __('View Contacts'),
    'view_item' => __('View Contact'),
    'search_items' => __('Search Contacts'),
    'not_found' =>  __('No Contacts found'),
    'not_found_in_trash' => __('No Contacts found in Trash'), 
    'parent_item_colon' => '',
    'menu_name' => 'Contacts'
    );

    $tpf_cnm_type_args = array(
        'labels' => $tpf_cnm_type_labels,
        'public' => true,
        'publicly_queryable' => true,
        'show_ui' => true, 
        'show_in_menu' => true, 
        'query_var' => true,
        'rewrite' => array( 'slug' => _x( 'contact-manager', 'URL slug', 'your_text_domain' ) ),
        'capability_type' => 'post',
        'has_archive' => true, 
        'hierarchical' => false,
        'menu_position' => null,
        'supports' => array( 'title', 'comments', 'custom-fields' )
      ); 

    register_post_type('tpf_cnm', $tpf_cnm_type_args); 
    }

any help would be nice im going crazy with this atm thank you all in advance

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

I think you may need to correct:

'post-type' => 'tpf_cnm',

and make it:

'post_type' => 'tpf_cnm',

share|improve this answer
    
Oh my god your right damn i feel like a fool haha thank you for pointing that out i guess i looked at all the wrong spots –  Mike Jr. Nov 18 '13 at 23:14
add 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.