I want to add posts to a custom post type via GravityForms. I have successfully set this up in GravityForms and when the form is submitted the correct post type is set to the post and even a custom taxonomy is set.
However the image upload doesn't seem to work. No images show up in the post / WordPress Media Library. The images do show up when viewing entries in the GravityForms interface.
Any ideas what may be causing this? It works just fine when it's just a default post that gets added instead of setting a custom post type. Here's the code that creates the post type:
// Photos post type
register_post_type( 'sp_photos',
array(
'labels' => array(
'name' => __( 'Photos' ),
'singular_name' => __( 'Photo' ),
'add_new' => __( 'Add New' ),
'add_new_item' => __( 'Add New Photo' ),
'edit' => __( 'Edit' ),
'edit_item' => __( 'Edit Photo' ),
'new_item' => __( 'New Photo' ),
'view' => __( 'View' ),
'view_item' => __( 'View Photo' ),
'search_items' => __( 'Search Photos' ),
'not_found' => __( 'No photos found' ),
'not_found_in_trash' => __( 'No photos found in Trash' ),
),
'public' => true,
'show_ui' => true,
'publicly_queryable' => true,
'exclude_from_search' => true,
'hierarchical' => false,
'supports' => array( 'title', 'editor', 'custom-fields', 'thumbnail' ),
'rewrite' => array( 'slug' => 'photos', 'with_front' => false ),
'can_export' => true,
)
);
And what changes the post type in the form in GravityForms:
/**
* Sets our custom post types and taxonomies
*/
function sp_gravity( $post_data, $form ) {
if( $form["id"] == '5' ) {
// Set our custom post type
$post_data["post_type"] = "sp_photos";
}
return $post_data;
}
add_filter( 'gform_post_data', 'sp_gravity', 10, 2 );