I try to modify a function in a wordpress plugin, who notify administrators by email, that a new post on bbPress forum or answer are created.
I managed to have multiple recipients.
Now I want to have the email of the user who post in the forum.
Actually, I have the display name of the poster.
I try this :
function notify_admin($post_id) {
if (get_option(self::TD . 'notify')) {
$multiple_recipients = array(
'xxx@xxxx.xxx',
'xxx@xxxx.xxx',
'xxx@xxxx.xxx'
);
$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
$blogurl = get_option('home');
$message = sprintf(__('Nouveau sujet ou réponse en attente de moderation sur le site %s: %s', self::TD), $blogname, $blogurl) . "\r\n\r\n";
/* Add body of topic/reply to email */
$post = get_post($post_id);
$title = '';
if ($post) {
$title = $post->post_title;
$message .= get_permalink($post->ID) . "\r\n\r\n";
$author = get_userdata($post->post_author); //HERE I WANT TO GET THE USER EMAIL
$email = get_userdata($post->user_email);
$message .= "Le contenu suivant a été posté\r\n";
if ($author !== false) {
$name = $author->user_firstname . " " . $author->user_lastname;
$name = trim($name);
if (empty($name)) {
$name = $author->display_name;
}
if ($name == $author->user_login) {
$name = '';
} else {
$name = ' (' . $name . ')';
}
$message .= "Par " . $author->user_login . $name . "\r\n\r\n";
} else {
$message .= "Par Anonyme\r\n\r\n";
}
$message .= $post->post_title . "\r\n" . $post->post_content . "\r\n\r\n";
$message .= "Pour modérer, cliquez ici : xxxxxxx";
$message .= $email . "\r\n"; //HERE I WANT TO PUT IT ON MY MAIL
}
@wp_mail(($multiple_recipients), sprintf(__('[%s] Moderation Forum', self::TD), $blogname, $title), $message);
}
}
With that, I don't have the $email fiel in my mail.
I'm not an expert on PHP, sorry if I do mistakes.
Can you help me please ?
0 comments:
Post a Comment