我刚刚开始制作插件,我正在尝试制作一个简单的插件,每当我发布新帖子时,它都会向订阅者发送通知。
迄今为止我的代码:
add_action( \'publish_post\', \'vb_esa_update_email\' );
function vb_esa_update_email( $post_id ) {
//verify post is not a revision
if ( !wp_is_post_revision( $post_id ) ) {
//gets subscirbers to send email to
// WP_User_Query arguments
$args = array (
\'role\' => \'Subscriber\',
);
// The User Query
$user_query = new WP_User_Query( $args );
$post_title = get_the_title( $post_id );
$post_url = get_permalink( $post_id );
$subject = \'A post has been updated\';
$message = "A post has been updated on your website:\\n\\n";
$message .= "<a href=\'". $post_url. "\'>" .$post_title. "</a>\\n\\n";
//send email to
foreach($args as $email_address)
{
wp_mail($email_address, $subject, $message );
}
}
}
如何用要向其发送通知的订阅者列表填充数组?