I'm working on a form that creates a Post where I want the post title to be dynamically generated from a number of other form fields (essentially, the title is a tracking code made up of other codes generated by other fields).
Using a content template on the Post Title does exactly what I want except for one thing: depending on the values a certain field (Form Field 7), the way the title is constructed changes. So I need to write a custom function that will create the Post Title based on some if statements.
Due to the way my site is managed, I prefer to do this as a plugin rather than in the themes functions.php file.
Here's what I've written:
add_filter("gform_post_data", "create_proposal_title", 10, 2);
function create_proposal_title($post_data, $entry) {
if ($entry['7'] == 'NEWPRG') {
$post_data['post_title'] = $entry['7']."-".$entry['17']."-".$entry['3']."-".$entry['9']."-".$entry['id'];
}
return $post_data;
}
However, this isn't working. I'm not sure what I'm doing incorrectly. Is there anything obvious with my syntax of use of the filter?