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.
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?
the terms
is for echoing . Useget_the_terms()
instead for returning values.as a rule of thumb, when you do not see the prefix
get_
in wordpress, the function will echo on the screen. likethe_title()
( echoing ) andget_the_title
(returning )..