【发布时间】:2019-05-28 23:15:18
【问题描述】:
| add_action('wpcf7_before_send_mail', 'save_application_form'); 函数 save_application_form($wpcf7) {
if ($wpcf7->id == 19) {
$client->setAccessToken($_SESSION['accessToken']);
$service = new Google_DriveService($client);
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$file = new Google_DriveFile();
$wpcf7 = WPCF7_ContactForm :: get_current() ;
$form_to_DB = WPCF7_Submission::get_instance();
if ($form_to_DB) {
/* @var $mail type */
$uploaded_files = $form_to_DB->uploaded_files(); // this allows you access to the upload file in the temp location
$fileId = '';
$cf7_file_field_name = 'file-181'; // [file uploadyourfile]
//Do the magic the same as the refer link above
$image_location = $uploaded_files[$cf7_file_field_name];
$mime_type = finfo_file($finfo, $image_location);
$file->setMimeType($mime_type);
$test = pathinfo($image_location);
$service->files->insert(
$file, array(
'data' => file_get_contents($image_location),
'mimeType' => $mime_type
)
);
$filetest = $service->files->get($fileId);
$add = $filetest['items'];
$final = $add[0]['alternateLink'];
// the message
$mail = "Link:" . $final;
$mail = $wpcf7->prop('mail') ;
$wpcf7->set_properties( array("mail" => $mail)) ;
// return current cf7 instance
return $wpcf7 ;
}
}
}
|我在该函数中有一个函数我有一个变量用于存储共享链接。我想将此变量传递给联系表格 7 邮件
【问题讨论】:
-
您想将自定义变量值发送到电子邮件中?
-
你得到变量值了吗?
-
是的,我想在邮件中发送自定义变量
-
是的,我得到了变量值。
-
@P.patel 问题解决了吗?