I'm trying to create a contact form that saves posts. Sort of like a in build ticketing system.
I'm using a drop down custom field with the title wpcf-post_title to set the title.
I'm using this code:
function set_custom_post_title( $args, $form_id, $form_data ) {
// Check if the form ID matches the desired form
if ( $form_id === 151341 ) {
// Get the value of the custom field 'wpcf-post_title' from the submitted form data
$custom_title = $form_data['fields']['wpcf-post_title'];
// Set the post title to the value of the custom field
$args['post_title'] = $custom_title;
}
The user is already logged in when submitting the form. The subject field decscription, rather than value would be great saved as the post title, maybe with their username next to it. For example; General Support - @username