-
Notifications
You must be signed in to change notification settings - Fork 1
/
cf-hide-email-notification.php
140 lines (128 loc) · 3.52 KB
/
cf-hide-email-notification.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<?php
/*
Plugin Name: CF Hide Email Notification
Description: Plugin for handling the blocking of Email confirmations for new users in a MultiSite install of WordPress.
Version: 1.2
Author: Crowd Favorite
Author URI: http://crowdfavorite.com
*/
/**
* Request Handler for functions related to this plugin
*
* @return void
*/
function cfhide_request_handler() {
// Get the JS File if it is asked for
if (!empty($_GET['cf_action'])) {
switch ($_GET['cf_action']) {
case 'cfhide_js':
cfhide_js();
die();
break;
default:
break;
}
}
// If the form is posted from the New User page, modify the $_POST
if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'adduser') {
$_POST['noconfirmation'] = 1;
$_REQUEST['noconfirmation'] = 1;
}
}
add_action('init', 'cfhide_request_handler', 1);
/**
* Enqueue the JS for the New User screen
*
* @return void
*/
function cfhide_enqueue_js() {
wp_enqueue_script('cfhide_js', admin_url('?cf_action=cfhide_js'), array('jquery') );
}
add_action('admin_print_scripts-user-new.php', 'cfhide_enqueue_js');
/**
* JS to be added to the New User screen to hide the noconfirmation checkbox
*
* @return void
*/
function cfhide_js() {
// Using JS to check and hide, essentially removes the checked
?>
jQuery(function($) {
$('input#noconfirmation').closest('tr').hide();
$("#message p").html('User has been added to your site.');
});
<?php
}
/**
* This function will block the Welcome email from being sent to the user
*
* @param int $user_id
* @param string $password
* @param array $meta
* @return bool
*/
function cfhide_email_confirmation($user_id = '', $password = '', $meta = '') {
return false;
}
add_filter('wpmu_welcome_user_notification', 'cfhide_email_confirmation', 10, 3);
/**
* Automatically activate the user just created instead of sending a confirmation email
*
* @param string $domain
* @param string $path
* @param string $title
* @param string $user
* @param string $user_email
* @param string $key
* @param string $meta
* @return bool
*/
function cfhide_email_confirmation_blog_notification($domain = '', $path = '', $title = '', $user = '', $user_email = '', $key = '', $meta = '') {
$result = wpmu_activate_signup($key);
return false;
}
add_filter('wpmu_signup_blog_notification', 'cfhide_email_confirmation_blog_notification', 10, 7);
/**
* Automatically activate the user just created instead of sending a confirmation email
*
* @param string $user
* @param string $user_email
* @param string $key
* @param string $meta
* @return bool
*/
function cfhide_email_confirmation_user_notification($user = '', $user_email = '', $key = '', $meta = '') {
$result = wpmu_activate_signup($key);
return false;
}
add_filter('wpmu_signup_user_notification', 'cfhide_email_confirmation_user_notification', 10, 4);
/**
*
* CF Readme Inclusion
*
**/
/**
* Enqueue the readme function
*/
function cfhide_add_readme() {
if(function_exists('cfreadme_enqueue')) {
cfreadme_enqueue('cf-hide-email-notifications','cfhide_readme');
}
}
add_action('admin_init','cfhide_add_readme');
/**
* return the contents of the links readme file
* replace the image urls with full paths to this plugin install
*
* @return string
*/
function cfhide_readme() {
$file = realpath(dirname(__FILE__)).'/readme/readme.txt';
if(is_file($file) && is_readable($file)) {
$markdown = file_get_contents($file);
$markdown = preg_replace('|!\[(.*?)\]\((.*?)\)|','![$1]('.WP_PLUGIN_URL.'/cf-hide-email-notifications/readme/$2)',$markdown);
return $markdown;
}
return null;
}
?>