I’m also looking for a way to do this.
But if you simply add “the_title()” to your e-mail, the email text would always be the title of your contact form – page, not the title of the referral post.
My approach was to do it with a hidden field, that contains a php-variable:
I’ve got one contact-form-page.
I access it via “https://myblog.com/contact-form?myreferral=1“.
myreferral is the ID of the referral post.
I’ve found a way to insert this variable as a hidden field into the contact form.
But that hidden field is not mailed.
$fcinteresting=$_GET['xyz'];
$form .= '<form action="' . $url . '" method="post" class="wpcf7-form"' . $enctype . '>';
$form .= '<div style="display: none;">';
$form .= '<input type="hidden" name="_wpcf7" value="' . $id . '" />';
$form .= '<input type="hidden" name="_wpcf7_version" value="' . wpcf7_version() . '" />';
$form .= '<input type="hidden" name="_wpcf7_unit_tag" value="' . $unit_tag . '" />';
$form .= '<input type="hidden" name="interesting" value="' . $fcinteresting . '" />';
This is where I inserted the hidden field “interesting”.
The field appears in the form markup, but it isn’t included in the mail.
Any idea ?