Version Description
ADDED: passing through the $notify variable, available sinds 4.6. This is for other plugins to override default sending to admin or user. Only useful if sending within this plugin is activated. UPDATED: updated with the newer pluggable send functions of wordpress 4.7. FIXED: Missing blogname in user email
Download this release
Release Info
Developer | Virgial |
Plugin | Manage Notification E-mails |
Version | 1.3.0 |
Comparing to | |
See all releases |
Code changes from version 1.2.0 to 1.3.0
includes/{pluggable-functions.php → pluggable-functions-1.2.php}
RENAMED
File without changes
|
includes/pluggable-functions-1.3.php
ADDED
@@ -0,0 +1,237 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
|
4 |
+
STOP SENDING NOTIFICATION MAILS TO THE USERS
|
5 |
+
version: 1.3.0
|
6 |
+
updated: the core pluggable function wp_new_user_notification
|
7 |
+
added: passing through the $deprecated and $notify
|
8 |
+
|
9 |
+
1.2.0 initial
|
10 |
+
*/
|
11 |
+
|
12 |
+
if (!defined('ABSPATH')) die();
|
13 |
+
|
14 |
+
$famne_options = get_option( 'famne_options' );
|
15 |
+
|
16 |
+
if (!function_exists('dont_send_password_change_email') ) :
|
17 |
+
/**
|
18 |
+
* Email password change notification to registered user.
|
19 |
+
*
|
20 |
+
*/
|
21 |
+
//echo "dont_send_password_change_email";
|
22 |
+
function dont_send_password_change_email( $send=false, $user='', $userdata='')
|
23 |
+
{
|
24 |
+
|
25 |
+
global $famne_options;
|
26 |
+
|
27 |
+
if (is_array($user)) $user = (object) $user;
|
28 |
+
|
29 |
+
if (!empty($famne_options['wp_password_change_notification']) ) :
|
30 |
+
|
31 |
+
// send a copy of password change notification to the admin
|
32 |
+
// but check to see if it's the admin whose password we're changing, and skip this
|
33 |
+
if ( 0 !== strcasecmp( $user->user_email, get_option( 'admin_email' ) ) ) {
|
34 |
+
$message = sprintf(__('Password Lost and Changed for user: %s'), $user->user_login) . "\r\n";
|
35 |
+
// The blogname option is escaped with esc_html on the way into the database in sanitize_option
|
36 |
+
// we want to reverse this for the plain text arena of emails.
|
37 |
+
$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
|
38 |
+
wp_mail(get_option('admin_email'), sprintf(__('[%s] Password Lost/Changed'), $blogname), $message);
|
39 |
+
}
|
40 |
+
|
41 |
+
endif;
|
42 |
+
|
43 |
+
if (empty($famne_options['send_password_change_email']) ) :
|
44 |
+
return false;
|
45 |
+
else :
|
46 |
+
return true;
|
47 |
+
endif;
|
48 |
+
}
|
49 |
+
add_filter('send_password_change_email', 'dont_send_password_change_email',1,3);
|
50 |
+
endif;
|
51 |
+
|
52 |
+
|
53 |
+
if (empty($famne_options['send_email_change_email']) && !function_exists('dont_send_email_change_email') ) :
|
54 |
+
/**
|
55 |
+
* Email users e-mail change notification to registered user.
|
56 |
+
*
|
57 |
+
*/
|
58 |
+
//echo "dont_send_email_change_email off";
|
59 |
+
function dont_send_email_change_email( $send=false, $user='', $userdata='')
|
60 |
+
{
|
61 |
+
return false;
|
62 |
+
}
|
63 |
+
add_filter('send_email_change_email', 'dont_send_email_change_email',1,3);
|
64 |
+
endif;
|
65 |
+
|
66 |
+
|
67 |
+
|
68 |
+
if (!function_exists('wp_new_user_notification') ) :
|
69 |
+
/**
|
70 |
+
* Email login credentials to a newly-registered user.
|
71 |
+
*
|
72 |
+
* A new user registration notification is also sent to admin email.
|
73 |
+
*/
|
74 |
+
//echo "wp_new_user_notification off";
|
75 |
+
function wp_new_user_notification( $user_id, $deprecated = null, $notify = '' ) {
|
76 |
+
|
77 |
+
global $famne_options;
|
78 |
+
|
79 |
+
if (!empty($famne_options['wp_new_user_notification_to_admin']))
|
80 |
+
{
|
81 |
+
fa_new_user_notification_to_admin($user_id,$notify);
|
82 |
+
}
|
83 |
+
|
84 |
+
if (!empty($famne_options['wp_new_user_notification_to_user']))
|
85 |
+
{
|
86 |
+
fa_new_user_notification_to_user($user_id,$deprecated,$notify);
|
87 |
+
}
|
88 |
+
}
|
89 |
+
endif;
|
90 |
+
|
91 |
+
if (empty($famne_options['wp_notify_postauthor']) && !function_exists('wp_notify_postauthor') ) :
|
92 |
+
/**
|
93 |
+
* Notify an author (and/or others) of a comment/trackback/pingback on a post.
|
94 |
+
*/
|
95 |
+
//echo "wp_notify_postauthor off";
|
96 |
+
function wp_notify_postauthor( $comment_id, $deprecated = null ) {}
|
97 |
+
endif;
|
98 |
+
|
99 |
+
if (empty($famne_options['wp_notify_moderator']) && !function_exists('wp_notify_moderator') ) :
|
100 |
+
/**
|
101 |
+
* Notifies the moderator of the blog about a new comment that is awaiting approval.
|
102 |
+
*/
|
103 |
+
//echo "wp_notify_moderator off";
|
104 |
+
function wp_notify_moderator($comment_id) {}
|
105 |
+
endif;
|
106 |
+
|
107 |
+
|
108 |
+
|
109 |
+
|
110 |
+
if (empty($famne_options['wp_password_change_notification']) && !function_exists('wp_password_change_notification') ) :
|
111 |
+
/**
|
112 |
+
* Notify the blog admin of a user changing password, normally via email.
|
113 |
+
*/
|
114 |
+
function wp_password_change_notification($user) {}
|
115 |
+
|
116 |
+
|
117 |
+
endif;
|
118 |
+
|
119 |
+
|
120 |
+
|
121 |
+
if ((empty($famne_options['send_password_forgotten_email']) || empty($famne_options['send_password_admin_forgotten_email'])) && !function_exists('dont_send_password_forgotten_email') ) :
|
122 |
+
/**
|
123 |
+
* Email forgotten password notification to registered user.
|
124 |
+
*
|
125 |
+
*/
|
126 |
+
//echo "dont_send_password_forgotten_email off";exit;
|
127 |
+
function dont_send_password_forgotten_email( $send=true, $user_id=0 )
|
128 |
+
{
|
129 |
+
global $famne_options;
|
130 |
+
|
131 |
+
$is_administrator = fa_user_is_administrator($user_id);
|
132 |
+
|
133 |
+
if ($is_administrator && empty($famne_options['send_password_admin_forgotten_email']))
|
134 |
+
{
|
135 |
+
// stop sending admin forgot email
|
136 |
+
return false;
|
137 |
+
}
|
138 |
+
if (!$is_administrator && empty($famne_options['send_password_forgotten_email']))
|
139 |
+
{
|
140 |
+
// stop sending user forgot email
|
141 |
+
return false;
|
142 |
+
}
|
143 |
+
// none of the above so give the default status back
|
144 |
+
return $send;
|
145 |
+
}
|
146 |
+
add_filter('allow_password_reset', 'dont_send_password_forgotten_email',1,3);
|
147 |
+
endif;
|
148 |
+
|
149 |
+
|
150 |
+
|
151 |
+
|
152 |
+
|
153 |
+
|
154 |
+
function fa_new_user_notification_to_admin ($user_id,$notify='')
|
155 |
+
{
|
156 |
+
|
157 |
+
//Most parts of this function are copied form pluggable.php
|
158 |
+
|
159 |
+
global $wpdb, $wp_hasher;
|
160 |
+
$user = get_userdata( $user_id );
|
161 |
+
|
162 |
+
// The blogname option is escaped with esc_html on the way into the database in sanitize_option
|
163 |
+
// we want to reverse this for the plain text arena of emails.
|
164 |
+
$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
|
165 |
+
|
166 |
+
if ( 'user' !== $notify ) {
|
167 |
+
$switched_locale = switch_to_locale( get_locale() );
|
168 |
+
$message = sprintf( __( 'New user registration on your site %s:' ), $blogname ) . "\r\n\r\n";
|
169 |
+
$message .= sprintf( __( 'Username: %s' ), $user->user_login ) . "\r\n\r\n";
|
170 |
+
$message .= sprintf( __( 'Email: %s' ), $user->user_email ) . "\r\n";
|
171 |
+
|
172 |
+
@wp_mail( get_option( 'admin_email' ), sprintf( __( '[%s] New User Registration' ), $blogname ), $message );
|
173 |
+
|
174 |
+
if ( $switched_locale ) {
|
175 |
+
restore_previous_locale();
|
176 |
+
}
|
177 |
+
}
|
178 |
+
}
|
179 |
+
|
180 |
+
|
181 |
+
function fa_new_user_notification_to_user($user_id,$deprecated=null,$notify='')
|
182 |
+
{
|
183 |
+
if ( $deprecated !== null ) {
|
184 |
+
_deprecated_argument( __FUNCTION__, '4.3.1' );
|
185 |
+
}
|
186 |
+
|
187 |
+
global $wpdb;
|
188 |
+
$user = get_userdata( $user_id );
|
189 |
+
|
190 |
+
// `$deprecated was pre-4.3 `$plaintext_pass`. An empty `$plaintext_pass` didn't sent a user notification.
|
191 |
+
if ( 'admin' === $notify || ( empty( $deprecated ) && empty( $notify ) ) ) {
|
192 |
+
return;
|
193 |
+
}
|
194 |
+
|
195 |
+
// The blogname option is escaped with esc_html on the way into the database in sanitize_option
|
196 |
+
// we want to reverse this for the plain text arena of emails.
|
197 |
+
$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
|
198 |
+
|
199 |
+
|
200 |
+
// Generate something random for a password reset key.
|
201 |
+
$key = wp_generate_password( 20, false );
|
202 |
+
|
203 |
+
/** This action is documented in wp-login.php */
|
204 |
+
do_action( 'retrieve_password_key', $user->user_login, $key );
|
205 |
+
|
206 |
+
// Now insert the key, hashed, into the DB.
|
207 |
+
if ( empty( $wp_hasher ) ) {
|
208 |
+
$wp_hasher = new PasswordHash( 8, true );
|
209 |
+
}
|
210 |
+
$hashed = time() . ':' . $wp_hasher->HashPassword( $key );
|
211 |
+
$wpdb->update( $wpdb->users, array( 'user_activation_key' => $hashed ), array( 'user_login' => $user->user_login ) );
|
212 |
+
|
213 |
+
$switched_locale = switch_to_locale( get_user_locale( $user ) );
|
214 |
+
|
215 |
+
$message = sprintf(__('Username: %s'), $user->user_login) . "\r\n\r\n";
|
216 |
+
$message .= __('To set your password, visit the following address:') . "\r\n\r\n";
|
217 |
+
$message .= '<' . network_site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user->user_login), 'login') . ">\r\n\r\n";
|
218 |
+
|
219 |
+
$message .= wp_login_url() . "\r\n";
|
220 |
+
|
221 |
+
wp_mail($user->user_email, sprintf(__('[%s] Your username and password info'), $blogname), $message);
|
222 |
+
|
223 |
+
if ( $switched_locale ) {
|
224 |
+
restore_previous_locale();
|
225 |
+
}
|
226 |
+
}
|
227 |
+
|
228 |
+
function fa_user_is_administrator($user_id=0)
|
229 |
+
{
|
230 |
+
$user = new WP_User( intval($user_id) );
|
231 |
+
$is_administrator = false;
|
232 |
+
if ( !empty( $user->roles ) && is_array( $user->roles ) ) {
|
233 |
+
foreach ( $user->roles as $role )
|
234 |
+
if ( strtolower($role) == 'administrator') $is_administrator = true;
|
235 |
+
}
|
236 |
+
return $is_administrator;
|
237 |
+
}
|
manage-notification-emails.php
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: Manage Notification E-mails
|
4 |
-
Plugin URI: http://www.freeamigos.mx/wp-plugins/manage-notification-emails/1.
|
5 |
Description: This plugin gives you the option to disable some of the notification e-mails send by Wordpress. It's a simple plugin but effective.
|
6 |
|
7 |
|
8 |
-
Version: 1.
|
9 |
Author: Virgial Berveling
|
10 |
Author URI: http://www.freeamigos.mx
|
11 |
License: GPLv2
|
@@ -59,7 +59,7 @@ License: GPLv2
|
|
59 |
|
60 |
if (!defined('ABSPATH')) die();
|
61 |
|
62 |
-
define( 'FA_MNE_VERSION', '1.
|
63 |
define( 'FA_MNE_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
|
64 |
define( 'FA_MNE_PLUGIN_DIR', untrailingslashit( dirname( __FILE__ ) ) );
|
65 |
|
@@ -79,7 +79,17 @@ function famne_init() {
|
|
79 |
endif;
|
80 |
}
|
81 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
|
83 |
-
include_once( FA_MNE_PLUGIN_DIR . '/includes/pluggable-functions.php' );
|
84 |
|
85 |
famne_init();
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: Manage Notification E-mails
|
4 |
+
Plugin URI: http://www.freeamigos.mx/wp-plugins/manage-notification-emails/1.3.0
|
5 |
Description: This plugin gives you the option to disable some of the notification e-mails send by Wordpress. It's a simple plugin but effective.
|
6 |
|
7 |
|
8 |
+
Version: 1.3.0
|
9 |
Author: Virgial Berveling
|
10 |
Author URI: http://www.freeamigos.mx
|
11 |
License: GPLv2
|
59 |
|
60 |
if (!defined('ABSPATH')) die();
|
61 |
|
62 |
+
define( 'FA_MNE_VERSION', '1.3.0' );
|
63 |
define( 'FA_MNE_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
|
64 |
define( 'FA_MNE_PLUGIN_DIR', untrailingslashit( dirname( __FILE__ ) ) );
|
65 |
|
79 |
endif;
|
80 |
}
|
81 |
|
82 |
+
/**
|
83 |
+
* Version switch.
|
84 |
+
*
|
85 |
+
* @since 1.3.0
|
86 |
+
*/
|
87 |
+
global $wp_version;
|
88 |
+
if (version_compare($wp_version, '4.7.0') >= 0) {
|
89 |
+
include_once( FA_MNE_PLUGIN_DIR . '/includes/pluggable-functions-1.3.php' );
|
90 |
+
}else {
|
91 |
+
include_once( FA_MNE_PLUGIN_DIR . '/includes/pluggable-functions-1.2.php' );
|
92 |
+
}
|
93 |
|
|
|
94 |
|
95 |
famne_init();
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: (Virgial)
|
|
3 |
Tags: notification,notify,email,user,password,moderator,postauthor,admin,e-mail,switch
|
4 |
Requires at least: 4.0.0
|
5 |
Donate link:https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=TYG56SLWNG42N
|
6 |
-
Tested up to: 4.
|
7 |
-
Stable tag: 1.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -30,12 +30,6 @@ Watch this nice tut made by Robert Orzanna: https://www.youtube.com/watch?v=66Uk
|
|
30 |
9. Forgotten password e-mail to administrator
|
31 |
|
32 |
|
33 |
-
**Coming soon:**
|
34 |
-
|
35 |
-
1. E-mail logging
|
36 |
-
2. html styling option for notification e-mails send to users
|
37 |
-
|
38 |
-
|
39 |
Want regular updates? Feel free to support me with a small donation :-)
|
40 |
|
41 |
|
@@ -55,6 +49,9 @@ Yes, after activating you can go to the settings page and disable or enable the
|
|
55 |
= Can I use this plugin for multisite? =
|
56 |
This plugin is not tested on multisite environments yet.
|
57 |
|
|
|
|
|
|
|
58 |
== Screenshots ==
|
59 |
|
60 |
1. This is your view of the settingspage.
|
@@ -64,11 +61,16 @@ If you're one of the early installers, than you'll be happy to see that de new u
|
|
64 |
|
65 |
== Changelog ==
|
66 |
|
67 |
-
= 1.
|
|
|
|
|
|
|
|
|
|
|
68 |
ADDED: Manage sending password forgot e-mail to registered user.
|
69 |
ADDED: Manage sending password forgot e-mail to administrator.
|
70 |
|
71 |
-
= 1.1.0 =
|
72 |
FIXED: Checking password change notification to admin now works.
|
73 |
ADDED: Splitted the manage option for new user notification e-mail into user and admin e-mail.
|
74 |
UPDATED: Clearified some comments and fixed some typo's.
|
3 |
Tags: notification,notify,email,user,password,moderator,postauthor,admin,e-mail,switch
|
4 |
Requires at least: 4.0.0
|
5 |
Donate link:https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=TYG56SLWNG42N
|
6 |
+
Tested up to: 4.8
|
7 |
+
Stable tag: 1.3.0
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
30 |
9. Forgotten password e-mail to administrator
|
31 |
|
32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
Want regular updates? Feel free to support me with a small donation :-)
|
34 |
|
35 |
|
49 |
= Can I use this plugin for multisite? =
|
50 |
This plugin is not tested on multisite environments yet.
|
51 |
|
52 |
+
= Disabling user notifications does not work =
|
53 |
+
Some other plugins also use their custom notifications which overwrite the core notifications of Wordpress. To be sure, please first try the plugin without other plugins installed or at least temporarily disable them.
|
54 |
+
|
55 |
== Screenshots ==
|
56 |
|
57 |
1. This is your view of the settingspage.
|
61 |
|
62 |
== Changelog ==
|
63 |
|
64 |
+
= 1.3.0 =
|
65 |
+
ADDED: passing through the $notify variable, available sinds 4.6. This is for other plugins to override default sending to admin or user. Only useful if sending within this plugin is activated.
|
66 |
+
UPDATED: updated with the newer pluggable send functions of wordpress 4.7.
|
67 |
+
FIXED: Missing blogname in user email
|
68 |
+
|
69 |
+
= 1.2.0 =
|
70 |
ADDED: Manage sending password forgot e-mail to registered user.
|
71 |
ADDED: Manage sending password forgot e-mail to administrator.
|
72 |
|
73 |
+
= 1.1.0 =
|
74 |
FIXED: Checking password change notification to admin now works.
|
75 |
ADDED: Splitted the manage option for new user notification e-mail into user and admin e-mail.
|
76 |
UPDATED: Clearified some comments and fixed some typo's.
|