Gravity form auto populating field not working

I am using gravity forms for wordpress and and i have following function to auto populate the form field:

add_filter('gform_field_value_vendor_category', 'populate_post_vendor_category');
function populate_post_vendor_category($value){

global $post;
$vendor_category = the_terms( $post->ID, 'listing_category');
return $vendor_category;
}

Adding the parameter name vendor_category to the form does not seem to work.

Read More

I have tried the following code on a template file and it displays the current listing category.

<?php global $post;
$vendor_cat = the_terms( $post->ID, 'listing_category');
echo $vendor_cat; ?>

Not sure why the field is not auto populating?

Related posts

Leave a Reply

1 comment

  1. the terms is for echoing . Use get_the_terms() instead for returning values.

    get_the_terms( $id, $taxonomy ); 
    

    as a rule of thumb, when you do not see the prefix get_ in wordpress, the function will echo on the screen. like the_title() ( echoing ) and get_the_title (returning )..