Themergency

Gravity Forms + Custom Post Types

Current version 3.0.1
Downloaded 13988 times!
View this page on WordPress.org

This plugin is an add-on for the Gravity Forms Plugin.
If you don’t yet own a license of the best forms plugin for WordPress, go and buy one now!

Gravity forms allows you to create posts from a form using ‘post fields’. By default the submitted form will create a post, but I wanted a way to save a custom post type instead. It can be done quite easily with some php code, but I wanted it to be easier without any code at all. Now it is easy. Maybe too easy :)

You can also link a custom taxomony to the field types : Drop Downs, Mulit Selects, Radio Buttons, Checkboxes and Single Line Text. So when the form is displayed a list of terms for the custom taxonomy are listed. And then when the post (or custom post type) is created, it automatically links the post to the selected taxonomy term(s).

features

  • Map a form to a custom post type (using the post title field)
  • Map fields (Drop Downs, Multiple Choice or Checkboxes) to a custom taxonomy
  • Supports Gravity Forms v1.5 and over (including v1.6)
  • Ability to have more than 1 taxonomy linked in a form (see screenshots)
  • Hierarchical dropdowns for hierarchical taxonomies (see screenshots)
  • Populate a dropdown with posts
  • Ability to set a parent post using the dropdown control
  • Single line text field can link to taxonomies by entering a comma seperated list
  • Enhanced UI on single line text fields to show a “tag input” styled control (see screenshots)

How to map a form to a custom post type

Add a post title field to your form and under the advanced tab, tick the “Save As Post Type” checkbox. A dropdown will appear with the available post types. Select the one you want.

How to link a field to a custom taxonomy

Custom taxonomies can be linked to Drop Downs, Mulit Selects, Radio Buttons and Checkboxes. Under the advanced tab for your field, tick the “Populate with a Taxonomy” checkbox. A dropdown will appear and you can select your custom taxonomy from the list.

How to link the saved post to taxonomies using a single line text field

You can also link a Single Line Text field to a taxonomy, so it can be used to input existing and new taxonomy terms. Under the Advanced tab, click “Save to Taxonomy” checkbox and then select the taxonomy from thr drop down. You can also choose to show an advanced UI by checking the “Enable enhanced UI” checkbox. This will enable an awesome “tag input” style control. See screenshot for more info. If the control contains exising terms, then they are linked to the saved post. If there are new terms in the control, then the terms are created and they are also linked.

How to set a parent post with the dropdown field

You can now link the dropdown field to a post type and try to make it set the parent item. Under the advanced tab, check the “Populate with Post Type” checkbox. Select the SAME post type that you selected when adding a post title field (above), and check “Try to set parent”. This then fills the dropdown with a list of existing posts, so when you save the form and the post is created, it trys to set the parent post to whatever was selected in the dropdown.

Download

Latest version: Download Gravity Forms + Custom Post Types v3.0.1 [zip]

Installation

  1. Upload the plugin folder ‘gravity-forms-custom-post-types’ to your /wp-content/plugins/ folder
  2. Activate the plugin through the ‘Plugins’ menu in WordPress
  3. Make sure you also have Gravity Forms activated.

FAQ

Q. Does this plugin rely on anything?
A. Yes, you need to install the Gravity Forms Plugin for this plugin to work.

Changelog

3.0.1

  • Fixed minor bug causing a PHP warning (FILE)
  • removed the restriction of not including scripts when a call is ajax

3.0

  • Removed support for Gravity Forms v1.4.5. Now supports v1.5 and up (including 1.6)
  • Added support for single line text fields
  • Added ability to populate a dropdown with posts
  • Added ability to set a parent post when saving a post form
  • Multiselect control now supports “populate with taxonomy” too
  • “first value” default overriden when populating with a taxonomy
  • Shows taxonomy selections when designing the form
  • Fixed support for conditional logic
  • Previews now load taxonomy terms
  • Previews can show enhanced UI (only in V1.6 and above)

2.0

  • Added support for both Gravity Forms v1.5 beta and v.1.4.5
  • Now supports linking taxonomies to Drop Downs, Multiple Choice or Checkboxes
  • Integrated with GF v1.5 hooks for easier configuration (thanks to Alex and Carl from RocketGenius)
  • Support linking more than 1 taxonomy to a form
  • To keep in line with the GF standards, mapping a form to a CPT in GF v1.4.5 can now be done via the ‘post title’ field

1.0

  • Initial Relase. First version.
Post comment as twitter logo facebook logo
Sort: Newest | Oldest
jmelon 5 pts

Hi,

 

There seems to be an issue with your GF plugin.

 

What is happening is that when I create a post via GF and enter multiple values for a taxonomy (separated by a comma) only one of the values gets saved.  Gravity Forms is showing all the data is being collected correctly in my form when I look at Entries raw data, but as soon as I post it to my custom post type the extra taxonomies are dropped. To make sure this was not an issue with my custom post types and taxonomies I tried to create a post using WP editor and everything posted fine, no taxonomies were dropped.

 

any thoughts how to fix that? I'm at a loss because I can't use GF and your plugin to create posts.

 

jlapitan 6 pts

assigning to custom fields is not working.

themergency 7 pts moderator

 jlapitan what type of custom field are you using?

johnchandler 5 pts

I have a special user role that is posting to a custom post type using a Gravity Form and this plugin. The custom post type has a custom capability called directory. Everything is working properly, except a custom Taxonomy called Specialties is not being properly assigned to the post. However, if I login as an Admin, the taxonomy is properly assigned.

 

The taxonomy has these capabilities:

   'manage_terms' => 'publish_directorys',

   'edit_terms' => 'publish_directorys',

   'delete_terms' => 'publish_directorys',

   'assign_terms' => 'publish_directorys'

 

Through the dashboard, I can both publish and edit the taxonomy connected to the custom post type, so this plugin seems to be what is limited the proper assignment of the taxonomy. Any ideas?

pet food brands 5 pts

I am getting notice like wp_smith. Any updates ?

themergency 7 pts moderator

 pet food brands are you using the latest version 3.0.1 ?

davkell 5 pts

Hey,

 

I need to assign all entries through a form to a particular custom taxonomy. I was thinking specifying the taxonomy and adding it to a hidden field when designing the form would make the most sense. Any pointers on the best way to go about doing that?

 

Great job on the plugin too - really useful.

wp_smith 5 pts

I am getting a notice: NOTICE: wp-content/plugins/gravity-forms-custom-post-types/gfcptaddon.php:62 - Use of undefined constant _FILE_ - assumed '_FILE_'. Can you please release an updated version?

joriswel 5 pts

Hey, in gfcptaddon.php you are using "_FILE_" (line 62) which gives me a warning (_FILE_ is undefined). Should this be "__FILE__"?

DarrylSchmidt 5 pts

While I'm here messagin', I really wish I could have gotten a pic of my face when I added a custom taxonomy via your plugin and it imported everything, as if by magic. I'm very impressed.

themergency 7 pts moderator

 DarrylSchmidt haha! glad you like it :)

DarrylSchmidt 5 pts

Any chance of adding Mappress support?

themergency 7 pts moderator

 DarrylSchmidt so you want to be able to select a location on the map when submitting the form?

SaschaPaukner 5 pts

 themergency Hi, I would very much like the possibility of choosing a location on a map and saving that to a custom field. I tried WP-Geo for that, but did not succees yet. Has anyone done anything similar? 

DarrylSchmidt 5 pts

 themergency Yes, I need to be able to specify a location on a map, but the process has to be easy enough for non-techie people, as "regular" people would be filling the forms. Mappress does a good job, but it's near the top end of difficulty for some of the people that I deal with :) This would be a great paid add-on ;)

themergency 7 pts moderator

 DarrylSchmidt SaschaPaukner I will look more into MapPress and creating another add on

SaschaPaukner 5 pts

 themergency  DarrylSchmidt Hi there,

I found the comment again! Brad, do you know if that is something you will pursue in the near future?

SaschaPaukner 5 pts

Hi there,

I would like to populate a dropdown from a hierarchical taxonomy. That works great with your plugin. Now the only thing I would like to change is: if there is a child category chosen, then the parent category gets selected automatically as well (this does not need to be visual during the selction process!). Is there a "upgrade safe" way to do this or do I have to hack your plugin? Could I use a after/pre submission GF filter/hook?

Would you anyone know how to add this functionality?

Many thanks,Sascha

ionofzion 5 pts

Hi, I get the following error when trying to display a form:

Warning: Invalid argument supplied for foreach() in /var/www/tuis.feedmydemo.co.za/wp-content/plugins/gravity-forms-custom-post-types/gfcptaddonbase.php on line 50

Not sure what's causing this, I've tried deactivating and reactivating but no luck. What I'm trying to do is create a form for adding topics to bbpress forums (replacing the inbuilt 'add topic' form).

Have used this plugin many times before without issues, so a bit stumped. Anyway, thanks for the cool plugin, and hope you can help.

themergency 7 pts moderator

ionofzion It is difficult to tell without more info, or actually logging into the backend myself. Can you give some more info about the form and how you are using it? What taxonomy are you using if any? etc etc

ionofzion 5 pts

themergency The problem was due to me not calling the global theme options on that specific template part (the form id is saved as a theme option). The form now displays properly, but forum posts don't show up once I've posted them. bbPress uses two different post types for Forums and Topics. I've set the Title to 'Save as Post Type' Topics, and then added a drop down menu populated by the Post Type: Forums. However, the assigned forum is not saved for some reason, so the forum posts don't show up front-end unless I manually assign a forum to them.

giovainstall2 5 pts

it doesn't works for me. using last WP and Gravity form versions.

i've added a title field, checked "save as post type", selected my post type (eg:Product)

And when i add a product, the form is not displayed into the editing page.

Any idea?

themergency 7 pts moderator

I am not sure what you are trying to do? When you save as a post type, it means when someone fills out the form, the content will be saved as the custom post type selected, so you can edit and possibly publish the data for your website later. The plugin does not facilitate adding meta boxes to the custom post types

cna training online 6 pts

Gravity forms is really good, I'm doing good in my custom post type. This is good information actually that contributes great help and it actually helps me too to learn more about gravity forms.

craigedmonds 5 pts

I have a custom post type called SERVICES. This custom post type has a meta field called ecpt_listingaddress. How do I get the gravity form field to insert the data into that field?Your plugin is working in the fact that it creates the custom post type but I can only get the title and description inserted, all the other fields I cant get to insert the data.So it means when I go to the custom post type editing page in wp admin the new entry is there, but address field is blank.Any ideas?

GregMcRay 5 pts

Great plugin, but I'm having a problem I can't seem to resolve. A checkbox populated by a taxonomy is giving me a "field required" error on submit, but I have selected a choice. I can randomly select multiple boxes and get it to submit, but I cannot detect a pattern that is causing the problem. The field parameters are identical to another checkbox, but with a different taxonomy, that isn't giving me the same problem. Any ideas? Thanks!

simplistik 5 pts

I have one thing that I'd like to request be added to the next update. In the gfcptaddonbase.php I had to add:

add_filter('gform_admin_pre_render' , array(&$this, 'setup_form') );

just below

add_filter('gform_pre_render' , array(&$this, 'setup_form') );

This solved a couple issues for me:

1. It will also dynamically populate the form on the backend when you're selecting to dynamically populate with a custom taxonomy. Instead of just showing nothing.

2. If this doesn't exist, and you "require" the fieldset (I only tested w/ checkboxes), it doesn't allow you leave the first checkbox unchecked. This fixes that issue.

spanky 5 pts

I received the following error upon trying to activate the plugin:

Fatal error: Class 'GFAddonCommon' not found in /data/14/1/126/50/1289376/user/1379660/htdocs/wp/wp-content/plugins/gravity-forms-css-ready-selector/gf-readyclasses-addon.php on line 51

jlapitan 6 pts

i have some problems with passing custom fields value to custom post types