Solution:
If you want to use your custom shortcode in VC, you can simply use shortcode mapper located at Visual Composer -> Shortcode Maper. After setup you can use your shortcode as any other VC component.
Speaking of your form, you can’t send it directly in the way it is now. You can process it with javascript/jQuery using ajax, but it’s kind of different story. If you want me, I can add it to my answer later.
If you want to use it in simple way, first of all, you should give names to your inputs. Second, you should put
<input type="submit">
inside your form. After that, form will be sent to the current page on submission, using POST method.
After that, put something like this in your functions.php to process the mail in simple way.
add_action( 'init', 'process_email' );
function process_email() {
if( isset( $_POST['your_required_input_name'] ) ) {
$name = $_POST['your_name_input_name'];
$txt = $_POST['your_message_input_name'];
$to = 'example@mail.com'; // put your email here
$subject = 'Put any subject here';
$message = 'Name: '.$name."\n\r".'Message: '.$txt;
$headers = 'From: example@mail.com' . "\r\n"; // put user's email here or duplicate your email
wp_mail($to, $subject, $message, $headers);
header('Location: '.$_SERVER['REQUEST_URI']);
die();
}
}
Also note that you can use CF7 plugin to generate ajaxy form and paste it inside your VC via shortcode.
——————————–UPDATED———————————-
If you want to process your form in ajax way, you can use jQuery for it. Usually it’s already enqueued on most of the themes, so just put something like this in your functions.php
add_action( 'wp_footer', 'process_email_by_ajax' );
function process_email_by_ajax() {
?>
<script>
(function($){
$('button.btn-primary').click(function(){
$.post(window.location.href, {
your_name_input_name: $('#recipient-name').val(),
your_message_input_name: $('#message-text').val()
}, function(){
alert('Yay! Success message!')
}).fail(function(){
alert('Oh no! Something goes wrong!')
})
return false;
})
})(jQuery)
</script>
<?php
}
It will send post query with your input & textarea data to the script, that is posted above. Note that you should change the $_POST[‘your_required_input_name’] to some required post param (ie your_name_input_name if you want the name to be required).