[英]Function to Send Email Notification to Author and Admin When Video is Uploaded
我一直在努力; 有人可以幫忙嗎?
我需要Wordpress Templatic Video主題來將用戶上載新視頻時發送給用戶的電子郵件副本發送給管理員。 然后管理員將知道要登錄並發布視頻。
主題應該這樣做,但事實並非如此。 所以,我要去
主題URL為: http : //www.wordpressdirectorytemplates.com/motaz/video
用戶上傳視頻時發送電子郵件的功能是:
/* send email of video post & update submit*/
global $post;
$post = get_post($last_postid);
$author = $post->post_author;
$name = get_the_author_meta( 'display_name', $author );
$email = get_the_author_meta( 'user_email', $author );
$title = $post->post_title;
$to[] = sprintf( '%s <%s>', $name, $email );
$subject = sprintf( 'Video Post: %s', $title );
$message = '';
$message .= "<p>Dear $name</p>";
if(isset($_REQUEST['pid']) && $_REQUEST['pid']!="")
{
$message .= '<p class="sucess_msg_prop">'. __('Thank you for submitting your video at our site, your request has been updated successfully.','templatic').'</p>';
}else{
/* if user set by default status publish than show different message */
$theme_settings = get_option('video_theme_settings');
if(isset($theme_settings['video_default_status']) && $theme_settings['video_default_status'] == 'publish'){
$message .= '<p class="sucess_msg_prop">'.__('The video will goes live on the site.','templatic').'</p>';
}else{
$message .= '<p class="sucess_msg_prop">'.__('The video will require admin approval before it goes live on the site.','templatic').'</p>';
$message .= '<p class="sucess_msg_prop">'.__('You will get an email confirmation once your video has been published.','templatic').'</p>';
}
}
$message .= "<p>You can view your video on the following link</p>";
$message .= '<a href="'.get_permalink($last_postid).'">'.get_permalink($last_postid).'</a>';
$message .= "<p>Thank you</p>";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
$fromEmail = get_option('admin_email');
$fromEmailName = stripslashes(get_option('blogname'));
wp_mail( $to, $subject, $message, $headers );
wp_redirect(site_url().'/?page=success&pid='.$last_postid);
exit;
}
}
通過添加以下內容,我可以將電子郵件發送給管理員而不是用戶:
$multiple_recipients = array(
'info@example.com');
然后,將$ multiple_recipients放在以下內容的開頭:
wp_mail($multiple_recipients , $to, $subject, $message, $headers );
但是,這是完全錯誤的。 管理員確實收到了電子郵件,但用戶未收到他們的電子郵件。
我還嘗試使用WP Codex尋求幫助,將功能添加到子主題功能文件中。 但是,這也是不正確的:
function email_friends( $post_ID ) {
$friends = 'info@example.com';
wp_mail( $friends, "New Video Uploaded", 'A new video has been uploaded on http://nuntim.com');
return $post_ID;
}
add_action( 'function video_posts_submition_success_msg_fn', 'email_friends' );
誰能指出我正確的方向?
您執行了錯誤的add action
請參見此處的Wiki,
鈎子video_posts_submition_success_msg_fn
存在? 如果是,您可以添加類似這樣的操作
function email_friends( $post_ID ) {
// may you can play with $post_ID here
$friends = 'info@example.com';
wp_mail( $friends, "New Video Uploaded", 'A new video has been uploaded on http://nuntim.com');
// return $post_ID; // add_action doesn't have return
}
add_action( 'video_posts_submition_success_msg_fn', 'email_friends', 10, 1 );
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.