我得到了一个非常简单的函数,它可以使用表单中的值简单地发送邮件。
一切正常,t值传递到wp\\u邮件,然后发送出去,没有问题。
但出于某种原因
setcookie(\'my_cookie\', $usersemail, 1 * DAYS_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN );
即使我知道
function set_user_cookie() {
$school = "Some Value";
setcookie(\'default_school\', $school, time()+3600);
}
add_action( \'init\', \'set_user_cookie\');
这似乎不起作用,完整功能如下:
function deliver_mail() {
// if the submit button is clicked, send the email
if ( isset( $_POST[\'cookieformSubmit\'] ) ) {
// sanitize form values
$name = sanitize_text_field( $_POST["cookieForm_name"] );
$email = sanitize_email( $_POST["cookieForm_email"] );
$number = sanitize_text_field( $_POST["cookieForm_number"] );
$downloadurl = sanitize_text_field( $_POST["cookie_download_url"] );
$message = \'\';
$message .= $name;
$message .= $email;
$message .= $number;
$message .= $downloadurl;
// get the blog administrator\'s email address
$to = \'[email protected]\';
$headers = "From: $name <$email>" . "\\r\\n";
// If email has been process for sending, display a success message
if ( wp_mail( $to, $subject, $message, $headers ) ) {
echo \'<div>\';
echo \'<p>Thanks for contacting me, expect a response soon.</p>\';
echo \'</div>\';
setcookie(\'hbp_cookie_doc_download\', $email, 1 * DAYS_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN );
} else {
echo \'An unexpected error occurred\';
}
}
}
我收到了短信“谢谢联系我,期待尽快回复。”当我提交表单时,我知道它已经达到了这一点,但由于某些原因,它只是没有设置cookie。我没有使用ingonito模式,我没有任何广告拦截器,我接受cookies。
因此,我不确定我做错了什么,任何想法都会得到极大的赞赏。
干杯
乔希