[Plugin: Gravity Forms + Custom Post Types] Automatically Choose Category (3 posts)

  1. Jonathan
    Posted 4 years ago #

    First of all, still love this plugin. It's awesome and great work.

    I am trying to map a form to a custom post type and tag it with a particular category automatically. For example, I want the post to automatically have category X while the user doesn't even see an option to choose the category. Is this possible with the plugin?

    Thank you.

  2. jaznz
    Posted 4 years ago #

    I need to achieve exactly the same thing.

    I have options for user to select regional location in my Gravity form, which maps beautifully to these subcategories, but I need the parent category to be checked by default and therefore mapped to by default without the user seeing this.

    Any ideas?


  3. Jonathan
    Posted 4 years ago #

    I'm not exactly sure how you have everything setup, but you most likely want to use the gform_pre_submission hook to adjust the form. Since I did this a while ago, I've forgotten a lot of how it is done, but the code I have within the hooked function is:

    //Set the category to be education
    //Education is category ID 9
    $_POST['input_9_1'] = 9;

    This is where education was the category I wanted chosen by default.

    I hope that's at least slightly helpful for you.

Topic Closed

This topic has been closed to new replies.

About this Topic