Hi,
für den Blog unserer Kanzlei suche ich eine Möglichkeit 3 Administratoren per e-Mail über neue Entwürfe zu informieren. Ich hatte bereits Notify on Draft Post und WP Post Notifier For All versucht dazu zu bringen, aber vergebens.
Danach fiel mir das Draft Notification Plugin von Dagon Design in die Hände. Im Prinzip funktionierte das halbwegs, jedoch sendet es an alle Benutzer eine Mail und nicht nur den Admins (man kann dies über
einstellen, allerdings kann ich 7,8,9 und 10 dort eingeben, es sendet trotzdem an alle, weiterhin sendet es die Benachrichtigung 4-6 mal an jede E-Mail Adresse (WTF???)
Wo könnte der Fehler liegen ? Unten ist das gesamte Script eingefügt.
PHP
<?php
/*
Plugin Name: Draft Notification
Plugin URI: http://www.dagondesign.com/articles/draft-notification-plugin-for-wordpress/
Description: Sends an email to the site admin when a draft is saved.
Author: Dagon Design
Version: 1.22
Author URI: http://www.dagondesign.com
*/
function dddn_process($id) {
// emails anyone on or above this level
$email_user_level = 7;
global $wpdb;
$tp = $wpdb->prefix;
$result = $wpdb->get_row("
SELECT post_status, post_title, user_login, user_nicename, display_name
FROM {$tp}posts, {$tp}users
WHERE {$tp}posts.post_author = {$tp}users.ID
AND {$tp}posts.ID = '$id'
");
if (($result->post_status == "draft") || ($result->post_status == "pending")) {
$message = "";
$message .= "A draft was updated on '" . get_bloginfo('name') . "'\n\n";
$message .= "Title: " . $result->post_title . "\n\n";
// *** Choose one of the following options to show the author's name
$message .= "Author: " . $result->display_name . "\n\n";
// $message .= "Author: " . $result->user_nicename . "\n\n";
// $message .= "Author: " . $result->user_login . "\n\n";
$message .= "Link: " . get_permalink($id);
$subject = "Draft Updated on '" . get_bloginfo('name') . "'";
$editors = $wpdb->get_results("SELECT user_id FROM {$tp}usermeta WHERE {$tp}usermeta.meta_value >= " . $email_user_level);
$recipient = "";
foreach ($editors as $editor) {
$user_info = get_userdata($editor->user_id);
$recipient .= $user_info->user_email . ',';
}
mail($recipient, $subject, $message);
}
}
add_action('save_post', 'dddn_process');
?>
Alles anzeigen
Der Blog liegt unter http://www.consulting-klar.de/skk/wp/
Grüße Oli