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.

Failed Custom Post Type Snippet

  1. cbisel
    Member

    I followed a thread in this forum to use a gravity form and have it convert a post to a custom post type I created called "companies". (It's closed so I can't add a comment to it) Here was the code I put in my custom.functions.php based on the example given:

    add_filter( "gform_post_data", "update_post_type", 10, 2 );
    function update_post_type( $post_data, $form ) {
    	if( $form["id"] == '2' ) {
    		// Set our custom post type
    		$post_data["post_type"] = "companies";
    	}
    	return $post_data;
    }

    It sort of worked. The test I did of the form was submitted, and a draft post called "Love this photo" was made in my companies list of posts, but instead of it being in blue (like a hyperlink), the title of the post is black (so I can't click on it) and there is no check box next to it. Also when I hover over it, there are no options popping up for me to edit it. So it's just sitting in my list of other "companies" I made the normal way (not through a gravity form) and I can't edit it or delete it.

    Here's what the post looks like in my list: http://tinypic.com/r/o9iavo/3

    I am way stuck. What do I do to not only edit/delete this test post but also fix it so future posts are editible?

    Thanks for any help
    Curtis

    Posted 13 years ago on Monday July 26, 2010 | Permalink
  2. sdever
    Member

    Hi, I am also looking for help in this area! Have read the forum thread referenced above, but have not been able to make this work. Where should I be adding the code snippet?

    Thanks so much for any help
    Sarawan

    Posted 13 years ago on Saturday July 31, 2010 | Permalink
  3. sdever
    Member

    Never mind my last post, pasted it in functions.php and it worked fine for me.

    Posted 13 years ago on Sunday August 1, 2010 | Permalink
  4. @cbisel There shouldn't be anything wrong wrong with the code snippet (see the user above who put it in his functions.php and it worked fine). Where have you placed the code? In your functions.php? If it isn't working it could be some other custom code on your site that is causing a conflict with it. Double check the rest of your code in your functions.php file and make sure everything looks okay and then make sure this code is in your functions.php file and not in a theme file, etc.

    Posted 13 years ago on Sunday August 1, 2010 | Permalink
  5. @cbisel: I am having the same issue as you!

    @ Carl: This code allows the Form to create the entry in my Custom Post Type, but does not give me the permission to edit the item. (e.g., The reason that it is in black instead of the usual blue, clickable link, BTW).

    Any idea on why there would be a permission issue here?

    Posted 13 years ago on Sunday August 29, 2010 | Permalink
  6. @veritrope Sounds like a role capabilities permission issue. Do you have any sort of role management plugin running or have you customized capabilities for roles?

    Posted 13 years ago on Monday August 30, 2010 | Permalink
  7. @Carl -- Thanks for your quick reply!

    Since I don't have any role management plugins, I went spelunking through the functions.php file and the DB table to see if I could figure out what was different.

    When I set up the Custom Post Type, I called it "code" -- and when I set up the Gravity Forms hook, I called it "Code". The difference in capitalization seemed to allow "Form Generated posts" to appear in the Post Type, but not allow it to be edited! I edited the posts in the DB and the problem was resolved.

    I am looking forward to the add-in -- and, should you want any extra beta testers for it, you know where to find me! ;)

    Posted 13 years ago on Monday August 30, 2010 | Permalink