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.

Custom taxonomies for post forms

  1. It would be great to have support for custom taxonomies in the post tag field.

    Cheers!

    Posted 12 years ago on Saturday January 2, 2010 | Permalink
  2. Well, for anybody looking to implement cutom taxonomies, you can do it by using the gform_post_submission hook and custom fields. Something like this:

    function tj_add_xtra_data( $form )
    {
    	if( $form['source_url'] == get_permalink( 824 ) )
    	{
    		require_once( WP_CONTENT_DIR . '/plugins/geo-mashup/geo-mashup-db.php' );
    
    		$id = $form['post_id'];
    		$lat = $form['8'];
    		$lng = $form['14'];
    
    		$post_location['lat'] = trim( $lat );
    		$post_location['lng'] = trim( $lng );
    
    		// save the location
    		GeoMashupDB::set_post_location( $id, $post_location );
    
    		// set the custom taxonomies
    		wp_set_object_terms( $id, $form['10'], 'countries' );
    		wp_set_object_terms( $id, $form['11'], 'continents' );
    		wp_set_object_terms( $id, $form['12'], 'cities' );
    
    		// delete all unneeded post meta
    		delete_post_meta( $id, 'tj_longitude' );
    		delete_post_meta( $id, 'tj_latitude' );
    		delete_post_meta( $id, 'tj_continent' );
    		delete_post_meta( $id, 'tj_country' );
    		delete_post_meta( $id, 'tj_city' );
    	}
    }
    add_action( 'gform_post_submission', 'tj_add_xtra_data' );

    What I did here was also integrate GF with the GeoMashup plugin. At the beginning I check for the correct form and in the end I delete all the post meta we don't need any more. All you'd have to do is change the field numbers/permalink id around to fit your needs.

    Posted 12 years ago on Saturday January 2, 2010 | Permalink
  3. Nice! We do plan on adding native support for custom taxonomies as an option on the Post Tag field. It's good to see you putting the available hooks to accomplish things. Good stuff.

    Posted 12 years ago on Saturday January 2, 2010 | Permalink
  4. I've actually been thinking about it and I'll probably leave my solution in once you add support for custom taxonomies. I only want my users to add one tag. I guess native support would allow multiple tags...

    Posted 12 years ago on Monday January 4, 2010 | Permalink
  5. Yes, but we may be able to set it up so that you can set a limit on how many tags and then validation can check to see how many tags were submitted and throw a validation error if they submit more than the limit was set to.

    Posted 12 years ago on Monday January 4, 2010 | Permalink
  6. Now that would be perfect :)

    Posted 12 years ago on Monday January 4, 2010 | Permalink
  7. sproutventure
    Member

    Am I missing options for custom taxonomies within the latest version?

    Is there a development version that has the ability?

    Thanks.

    Posted 12 years ago on Friday May 7, 2010 | Permalink
  8. No, we don't have built in support for custom taxonomies via the UI. However, we do have hooks that can be used to accomplish that.

    Posted 12 years ago on Friday May 7, 2010 | Permalink
  9. I am looking to implement forms solution with geo-Mashup plugin but would like to avoid coding a solution as Boris did.

    Is there a GUI based solution to geo-mashup integration that requires no coding now?

    Cheers
    Ben

    Posted 11 years ago on Saturday November 6, 2010 | Permalink
  10. Matosd
    Member

    I am also extremely interest about that!!!

    Posted 10 years ago on Monday January 9, 2012 | Permalink
  11. @Matosd, have you seen this 3rd party plugin at the WordPress repository?

    http://wordpress.org/extend/plugins/gravity-forms-custom-post-types/

    It was not created by us, but might help you.

    Posted 10 years ago on Tuesday January 10, 2012 | Permalink