我一直在挣扎;有人可以帮忙吗?
我需要Wordpress Templatic Video主题发送用户上传新视频时发送给客户的电子邮件副本。然后管理员将知道登录并发布视频。
主题应该这样做,但事实并非如此。所以,我有一个去吧
主题网址为: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' );
有人能指出我正确的方向吗?
答案 0 :(得分:0)
你做错了add action
看到了wiki Allow host to specify keep alive times,
是钩子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 );