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.

Form to Custom Post Type -Again

  1. lsparks
    Member

    I am attempting to implement custom post types via the instructions on http://forum.gravityhelp.com/topic/add-a-form-to-create-a-new-custom-post-type. I would have posted this there but the topic is closed. As of Wordpress 3.01 the filter update_post_type() no longer appears to work.

    This example code:

    add_filter("gform_post_data", "update_post_type",10,2);
    function set_post_type($post_data, $form){
    echo"<pre>";print_r($post_data);echo"</pre>";
    
        if($form["id"] == '1'){
            $post_data["post_type"] = "investments";
        }
        return $post_data;
    }

    results in this error:

    Fatal error: Cannot redeclare set_post_type() (previously declared in post.php:1062) in wp-content/themes/twentyten/functions.php on line 153

    Any suggestions?

    Thanks!

    Posted 14 years ago on Thursday November 4, 2010 | Permalink
  2. That is because that example code is old and stil using "set_post_type" and not "update_post_type" which is why the error is about "set_post_type". Change the code to use update_post_type instead and give it a try.

    Look at line 3 in the above code. function set_post_type is incorrect. Where you made the change isn't where the actual function call takes place.

    Posted 14 years ago on Thursday November 4, 2010 | Permalink