I am using Gravity Forms to allow users to create posts from the front end.
However, the way this site I am building is going to work, one specific Post_Type is essentially just a “Data” post. There is a specific Taxonomy who’s Terms are actually the “Title” of the data set.
I have already figured out a way to hide the “Title” field in Gravity forms but still have it present on the form (for some reason they lock the “Post_Type” and “Post Status” into the ‘Title’ field in the GUI, so I overloaded it’s conditional logic to force it to always hide).
I want to create a filter that would always copy the [Term] value for a specific [Taxonomy] into the [Title] field of a specific [Post_Type].
Any advice I could get on how to accomplish this would be great! Thanks in advance!
==============================================================
OK, using code from @Manny Fleurmond below, and from this post: Title_save_pre – Simple problem that u know for sure
I came up with
function taxonomy_title_rename($title) {
global $post;
$type = get_post_type($post->ID);
if ($type== 'CUSTOM_POST_TYPE') {
if($post->post_type === 'CUSTOM_POST_TYPE') {
$terms = wp_get_object_terms($post->ID, 'MY_TAXONOMY');
if(!is_wp_error($terms) && !empty($terms)) {
$title = $terms[0]->name;
}
}
return $title;
}
else if ($type != 'CUSTOM_POST_TYPE') {
return $title;
}
}
add_filter ('title_save_pre','taxonomy_title_rename');
This is actually saving the post title to the post from the taxonomy. However, it is not then pulling it into the permalink as well, my permalink is just the post ID number. Will see if I can get this solved on my own, but any help would be appreciated!