PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Custom post types on WP 3.0 - Image upload woes

  1. Danny
    Member

    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 );
    Posted 13 years ago on Tuesday June 29, 2010 | Permalink
  2. Danny,
    I used your custom post type code and the Gravity Forms hook code above and the post image is making into the gallery Ok. I am not sure what could be causing this issue on your end, but you may want to try to create a new form with just a post title and a post image field to make sure it is not a conflict between fields in your form.
    Let me know how that goes.

    Posted 13 years ago on Wednesday June 30, 2010 | Permalink
  3. Danny
    Member

    I created a form from scratch as you suggested with just the title and the image and it worked. Then I added all the other fields exactly like in the other form and everything works properly.

    Then I tried the old one again and that one still doesn't work. Tried the new one and it works just fine.

    Weird stuff. Guess I'll just re-do all the forms from scratch.

    Posted 13 years ago on Wednesday June 30, 2010 | Permalink
  4. It is strange. I am glad it worked with the new form

    Posted 13 years ago on Monday July 12, 2010 | Permalink
  5. test

    Posted 13 years ago on Monday July 12, 2010 | Permalink
  6. What the heck. That's Crazy!! I'm really not that interested, I'm just testing something so just ignore what I'm saying here.

    Posted 13 years ago on Monday July 12, 2010 | Permalink