Gravity Forms + Custom Post Types
Custom user taxonomies (4 posts)

  1. snails07
    Posted 4 years ago #

    Hi, wondering if it is possible to get this plugin working with custom user taxonomies and the user registration add on?
    Here's an article on user taxonomies that I have followed - http://justintadlock.com/archives/2011/10/20/custom-user-taxonomies-in-wordpress

    I have these all set up and they are working great and are showing up on the 'Populate with a Taxonomy' option within gravity forms.
    So all works well until I go to the User Registration Settings (with the add on) but there are only options to add standard user fields or user_meta fields.
    There is no option to add a custom user taxonomy.

    I know this might be a pretty odd request, but wondering if it might be included anytime??



  2. Mark
    Posted 3 years ago #

    Hi snails07, did you find a solution yet?
    Having the same needs.

    Kind regards

  3. Mark
    Posted 3 years ago #


    - Add the code below to the functions.php file.
    - Create a User object taxonomy. (eq. 'Professions')
    (with help from: justintadlock.com)
    - Now map the User Meta in the User Registation Add-on:
    'Professions' -> (Drop Down field - populated by a taxonomy)
    - The new function will now loops through all User meta. If a User meta keyname corresponse with a taxonomy name, the values are mapped.

    Ps. this solution does not support multi term selection (yet)

    Good luck!

    // Hook Gravity Forms user registration -> Map taxomomy
    	function map_taxonomy($user_id, $config, $entry, $user_pass) {
    		global $wpdb;
    	// Get all taxonomies
    		$taxs = get_taxonomies();
    	// Get all user meta
    		$all_meta_for_user = get_user_meta($user_id);
    	// Loop through meta data and map to taxonomies with same name as user meta key
    		foreach ($all_meta_for_user as $taxonomy => $value ) {
    			if (in_array ($taxonomy, $taxs) ) {			// Check if there is a Taxonomy with the same name as the Custom user meta key
    			// Get term id
    				$term_id = get_user_meta($user_id, $taxonomy, true);
    				If (is_numeric($term_id)) {				// Check if Custom user meta is an ID
    					Echo $taxonomy.'='.$term_id.'<br>';
    				// Add user to taxomomy term
    					$term = get_term( $term_id, $taxonomy );
    					$termslug = $term->slug;
    					wp_set_object_terms( $user_id, array( $termslug ), $taxonomy, false);
    	add_action("gform_user_registered", "map_taxonomy", 10, 4);
  4. Mark
    Posted 3 years ago #

    Small correction:
    - remove the 'Echo' command from the Foreach loop. =)

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Gravity Forms + Custom Post Types
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic