我正在使用高级Wordpress主题,我正在尝试获取主题附带的自定义联系表单,以便在成功完成后重定向到感谢页面(这是用于转换跟踪目的)
无论如何,这里是在页面上输入时调用短代码的代码
add_shortcode('etheme_contacts', 'etheme_contacts_shortcodes');
function etheme_contacts_shortcodes($atts, $content=null){
$a = shortcode_atts( array(
'gmap' => 1
), $atts );
if(isset($_GET['contactSubmit'])){
$emailFrom = strip_tags($_GET['contactEmail']);
$emailTo = etheme_get_option('contacts_email');
$subject = strip_tags($_GET['contactSubject']);
$name = strip_tags($_GET['contactName']);
$email = strip_tags($_GET['contactEmail']);
$message = strip_tags(stripslashes($_GET['contactMessage']));
$body = "Name: ".$name."\n";
$body .= "Email: ".$email."\n";
$body .= "Message: ".$message."\n";
$body .= $name.", <b>".$emailFrom."</b>\n";
$headers = "From: ".$emailFrom."\n";
$headers .= "Reply-To:".$emailFrom."\n";
if(isset($_GET['contactSubmit'])){
$success = mail($emailTo, $subject, $body, $headers);
if ($success){
echo '<p class="yay">All is well, your e–mail has been sent.</p>';
}
} …Run Code Online (Sandbox Code Playgroud)