WordPress is really powerful. It is powerful from the start, but its power also stems from the large offering of plugins it provides. However, I did not found one plugin that did what I wanted: receive notifications when one of your articles is modified by someone else. So I wrote my own, taking another one as a start.
It is very basic and may not be suited for everyone’s need, but anyway, you can download it.
This work is based on the draft notification plugin.
<?php /* Plugin Name: Post notifier Plugin URI: https://www.x2b4.com/ Description: Sends an email to the post author when a post is modified. Author: x2b4 Version: 1.0a Author URI: https://www.x2b4.com/ */ https://www.x2b4.com/based on http:https://www.x2b4.com/www.dagondesign.com/articles/draft-notification-plugin-for-wordpress/ function notification_process($id) { global $wpdb; $result = $wpdb->get_row(" SELECT post_status, post_title, user_login, user_nicename, display_name, {$wpdb->users}.ID FROM {$wpdb->posts}, {$wpdb->users} WHERE {$wpdb->posts}.post_author = {$wpdb->users}.ID AND {$wpdb->posts}.ID = '$id' "); global $current_user; get_currentuserinfo(); if (($result->ID != $current_user->ID)) { $message = ""; $message .= "A post has been edited on '" . get_bloginfo('name') . "'\n\n"; $message .= "Title: " . $result->post_title . "\n\n"; $message .= "Original author: " . $result->display_name . "\n\n"; $message .= "Editor: " . $current_user->display_name . "\n\n"; $message .= "Link: " . get_permalink($id) . "\n\n"; $result2 = $wpdb->get_row("SELECT {$wpdb->posts}.ID FROM {$wpdb->posts} WHERE `post_type` = 'revision' AND `post_parent` ='".$id."' ORDER BY `ID` DESC"); $message .= "Diff: ".get_bloginfo("wpurl")."/wp-admin/revision.php?action=diff&right=".$id."&left=".$result2->ID; $subject = "Post '" . $result->post_title . "' updated on '" . get_bloginfo('name') . "' by " . $current_user->display_name; $user_info = get_userdata($result->ID); $recipient = $user_info->user_email; $headers = 'From: WordPress<wordpress@x2b4.com>' . "\r\n"; mail($recipient, $subject, $message, $headers); } } add_action('publish_post', 'notification_process'); ?>
Salut,
Super plugin très simple et efficace.
J’aimerai le faire fonctionner sur un WP mulisite (MU ou network). Le plugin ne fonctionne que le WP principale et les sous sites.
Merci
@madgmartin
Qu’est ce qui ne marche pas exactement ?
@x2b4 merci pour ta réponse. J’ai fait 2 tests:
1/ Activation au niveau du network admin. les emails partent pour les modifications faites sur les articles publiés sur site http://www.lesite.com mais pas pour http://www.lesite.com/secondsite
2/ Activation seulement pour http://www.lesite.com/secondsite, aucun email n’est envoyés.
@madgmartin
J’aurais tendance à dire que c’est les préfixes de base de donnée qui sont incorrect.
Essaye de changer:
{$tp}users par {$wpdb->users}
et
{$tp}posts par {$wpdb->posts} dans le code (dans les requetes sql).
J’espère que cela corrigera le problème.
Merci 🙂
Je viens de modifier le plugin et je l’ai activé au niveau du network. Cela fonctionne parfaitement.
You can download the WordPress multsie (or WPMU) friendly version here: http://magdmartin.soup.io/post/123569309/post-notifierMS-ZIP-1-1-KB
Thanks