-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathno-email-change.php
62 lines (51 loc) · 1.17 KB
/
no-email-change.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
<?php
/*
Plugin Name: No Email Address Change!
Description: A simple plugin to disable email address changes for a user account.
Author: r-a-y
Author URI: http://profiles.wordpress.org/r-a-y
*/
/**
* Add 'readonly' to email field on "Users > Your Profile" admin page.
*/
add_action( 'show_user_profile', function() {
if ( is_super_admin() ) {
return;
}
$js = <<<JS
<script>
jQuery(function($){
$( '#email' ).prop('readonly', true);
});
</script>
JS;
echo $js;
} );
/**
* Hide email address field on "Users > Your Profile" admin page.
*/
add_action( 'admin_head-profile.php', function() {
if ( is_super_admin() ) {
return;
}
echo '<style type="text/css">tr.user-email-wrap {display:none}</style>';
} );
/**
* Add 'readonly' to email field on a user's "Settings > General" page.
*
* For BuddyPress.
*/
add_action( 'bp_before_member_settings_template', function() {
if ( is_super_admin() ) {
return;
}
ob_start();
}, 999999 );
add_action( 'bp_after_member_settings_template', function() {
if ( is_super_admin() ) {
return;
}
$contents = ob_get_clean();
$contents = str_replace( 'id="email"', 'id="email" readonly', $contents );
echo $contents;
}, -999999 );