Quantcast
Channel: WordPress.org Forums » [Forminator Forms – Contact Form, Payment Form & Custom Form Builder] Support
Viewing all articles
Browse latest Browse all 1398

Combining fields to generate post title

$
0
0

Replies: 0

I’m using Forminator to collect customer information and create a custom post utilizing the customer’s full name as the post title by updating the code that I found here:

https://wordpress.org/support/topic/post-data-title-generate-from-other-field/

add_action( 'wp_footer', 'wpmudev_radio_field_auto_selection', 9999 );
function wpmudev_radio_field_auto_selection() {
global $post;
if ( is_a( $post, 'WP_Post' ) && !has_shortcode( $post->post_content, 'forminator_form' ) ) {
return;
}
?>
<script type="text/javascript">
(function($) {
$.noConflict();
$(document).ready(function() {
setTimeout(function() {
$('.forminator-custom-form').trigger('after.load.forminator');
}, 1000);

$(document).on('after.load.forminator', function(event, form_id) {
if ( event.target.id == 'forminator-module-XXX' ) {
let _title = $('input[name="postdata-1-post-title"]');
_title.prop("readonly", true);

let _text = $('input[name="text-1"]');

$(_text).on("input", function() {
_title.val( $(this).val() );
});
}
});
});
})(jQuery);
</script>
<?php
}

The form works well, however, it only allows one name field to populate the post title at a time.

How can I modify the code so that it will to combine the First Name, Middle Name, and Last Name fields to populate the title field?


Viewing all articles
Browse latest Browse all 1398

Trending Articles