Viewing 11 replies - 1 through 11 (of 11 total)
  • If you want to use custom post types, you have to use the “Gravity Forms + Custom Post Types” plugin:
    https://www.ads-software.com/plugins/gravity-forms-custom-post-types/

    This plugin only allows you to update posts, that plugin expands your abilities to include custom post types and custom taxonomies.

    Thread Starter Dewey Bushaw

    (@styledev)

    What you say is true but the description for this plugin states: “Update or Delete Posts, Pages or Custom Post Types with Gravity Forms”

    This plugin can update custom post types, but Gravity Forms doesn’t support them without that plugin.

    So you are required to have the custom post type plugin in order to use custom post types with gravity forms.

    Thread Starter Dewey Bushaw

    (@styledev)

    I think that this requirement should be added to the Installation and/or FAQ page.

    It would probably be good to mention, I agree. Again, though, this is a requirement of Gravity Forms, not this plugin. This plugin uses the forms that are provided, and Gravity Forms can’t provide a custom post type form out of the box. So another plugin is needed. Just like Gravity Forms can’t edit posts out of the box. So another plugin is needed.

    Thread Starter Dewey Bushaw

    (@styledev)

    I see what you are saying but I would counter that one would be led to believe that you wouldn’t need any other plugin other than gravity forms and this one to edit a custom post type unless they already knew that you need that other plugin.

    Which is why it would be good to mention. I don’t disagree. This isn’t my plugin, and this plugin hasn’t been updated in a long time. I have a replacement for it that I am working on getting into the WordPress repo. It is currently here: https://bitbucket.org/jupitercow/gravity-forms-update-post

    When I get it in, I will make sure it is clearer.

    Thread Starter Dewey Bushaw

    (@styledev)

    Cool.

    Hey jcow, I’m actually looking at your in-progress replacement, particularly because I really like the direction you’re taking.

    One question–is there a way to override the post id in a hook after submission? I’m building a form that finds the custom post via a custom field then returns the post id. It seems like all the solutions out there either append a GET or hidden field (via smartcode).

    I’ve tried hijacking the value in gform_post_data and in the gform_validation with no luck.

    This is still Gravity Forms, so you can use the Gravity Forms hooks. Doesn’t gform_after_submission work?

    https://www.gravityhelp.com/documentation/page/Gform_after_submission

    In tutorials, they are always suggesting sending dates and user_ids and all kinds of crap through the forms, when you can usually just hook in there and get current user, or the current date and add them as needed. At least when you are working with post creation or update.

    I don’t think I explored that hook since it occurs after entry creation.

    I had a lot of inconsistent results (possible due to local caching and/or using the custom post type plugin). I actually gave up on this a few times. Ultimately, I got it to work doing a few things:

    I assigned the class instantiation to a variable by adding the following lines at L1101 of gravityforms-update-post.php:

    $gform_update_post = new gform_update_post();
    $gform_update_post::init();

    I then referenced it in my custom functions.php and had it assigned to the wp hook:

    global $gform_update_post;
    add_action( 'wp', array($gform_update_post, 'init'), 100 );

    In my validation script, I loop through custom posts, find the matching field, then retrieve its $post_id. With the global instance I then called:

    $gform_update_post::get_post_object($post_id);

    Lastly, I added a post_id via a shortcode on the page containing the form. I found that omitting the variable via query string or shortcode made it fail.

    [gform_update_post post_id=1]

    I suppose this could be optimized further, but I’ve easily surpassed the time I allocated toward this and am simply grateful that it’s now working.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Set Custom Post Type’ is closed to new replies.