OK, so I have a form with like 8 field groups with 3-4 sub-fields in each.
I'd like to send an email after form submission to admin including all those groups and sub-fields values and labels.
But I can't do that. I can include regular fields values (value 1 and 2 in my code), Value 3 is what gives me trouble.
This is what I'm trying to use:
add_action( 'rwmb_frontend_after_process', function( $config, $post_id ) {
if ( 'application_form' === $config['id'] ) {
$value1 = empty( $_POST['text_8qziiie3rt6'] ) ? null : $_POST['text_8qziiie3rt6'];
$value2 = empty( $_POST['text_text'] ) ? null : $_POST['text_text'];
$value3 = $group = rwmb_meta( 'contact', '', $post_id );
$t1 = $group['contact_1'];
$t2 = $group['contact_2'];
$to = '[email protected]';
$subject = 'New application';
$body = '<div class="mail-body" style="color:#ccc;">Your application details: ' . '' . '<div>' . 'Text 1:' . $value1 . '</div>' . '<div>' . 'Text 2:' . $value2 . '</div>' . '<div>' . 'Text 3:' . $value3 . '</div>' . 'This is it!</div>';
$headers = array( 'Content-Type: text/html; charset=UTF-8' );
wp_mail( $to, $subject, $body, $headers );
wp_safe_redirect( 'thank-you' );
die;
}
}, 10, 2 );
Also, is there a way to include all of those fields at once, like the entire form with the fields' values and names? I got around 30 fields....
Thank you for all your help, you're awesome.