Using a PHP form, get the page title or any other element in the sent e-mail

I am using a PHP form which I add in a page as a shortcode. I would like the user that receives the e-mail to also receive some indicator of the page the form was in…Is it possible to somehow get the value of anything in the page where the shortcode is placed?

This is the form’s send email function which generates the email content:

function send_email() {

// generate content
$content = “From: “.$_POST[‘mk-name’].”rnEmail: “.$_POST[‘mk-email’];

if(!empty($_POST[‘mk-company’])) {
$content .= “rnCompany: “.$_POST[‘mk-company’];
}

$content .= “rnrn”.$_POST[‘mk-message’];

// generate headers
$headers = ‘From: ‘.$_POST[‘mk-name’].’ <‘.$this->from.’>’.”rnReply-To: ” . $_POST[‘mk-email’].”rn”;

if(!empty($this->atts[‘cc’])) {
$headers .= ‘Cc: ‘.$this->atts[‘cc’].”rn”;
}
if(!empty($this->atts[‘bcc’])) {
$headers .= ‘Bcc: ‘.$this->atts[‘bcc’].”rn”;
}

// send email
wp_mail($this->to, $this->subject, $content, $headers);

}

Read more here:: Using a PHP form, get the page title or any other element in the sent e-mail

Leave a Reply

Your email address will not be published. Required fields are marked *