Hey again, @kaizerco!
If you plan to send your users a copy of their submission data, you won’t really need a shortcode. I’m sharing an example below, that simply replicates what happens with owner submission alerts. The outcome of this is that your users will receive a full copy of their submission:
function child_theme_happyforms_email_content( $content, $message, $to ) {
$form = happyforms_get_form_controller()->get( $message['form_id'] );
// Check if this is being sent to the site owner.
// If it is, return early because this isn't
// the email message we want to tweak.
if ( '[email protected]' === $to ) {
return $content;
}
$content_lines = array();
foreach ( $form['parts'] as $part_data ) {
$part_id = $part_data['id'];
$label = happyforms_get_email_part_label( $message, $part_data, $form );
$value = happyforms_get_email_part_value( $message, $part_data, $form );
$content_lines[] = "<b>{$label}</b><br>{$value}";
}
$content = implode( '<br><br>', $content_lines );
return $content;
}
add_filter( 'happyforms_email_content', 'child_theme_happyforms_email_content', 10, 3 );
I’d like to clarify some details:
1. HappyForms doesn’t support placeholders for rendering your submission data (like [first_name]
). That’s going to land at some point, but it’s not available yet.
2. If you want to render your own shortcodes inside your content, just add them in your Email content setting, and add a…
$content = do_shortcode( $content );
…before returning your content value.
I hope that does the trick! Let us know how that goes. ??