WordPress Multisite Email Hider

Virginia recently passed some FOIA legislation (and even more legislation) that says essentially that institutions can’t release student emails without written consent. That includes student directories and other fairly traditional things done with student emails.

It led us to look at our WordPress multisite install.1 While a VCU email address is required to sign up for rampages.us, the username can be whatever the person desires. Emails aren’t visible in the user directory. The one place we thought emails would be visible in way that might be unexpected was in the user view of individual sites. If a student is an admin, they’d be able to see the emails of other student users on that site.

The following bit of code removes the email column from the users view for everyone that isn’t a super admin.

add_filter('manage_users_columns','remove_users_columns');
function remove_users_columns($column_headers) {
            global $current_user;
            $super_admins = get_super_admins();         
            if ( is_array( $super_admins ) && in_array( $current_user->user_login, $super_admins ) ){
                return $column_headers;
            }
            else {
             unset($column_headers['email']);
             return $column_headers;
        }    

}

If we see an uproar from teachers about the missing column, we can also add people by user ID by doing something like . . . 2

$ok_people = [1,2,4];
if ( is_array( $super_admins ) && in_array( $current_user->user_login, $super_admins ) || in_array($current_user->ID, $ok_people) ){
[\php]


1 Overkill? Happy to oblige.

2 I didn’t test this yet so …

Comments on this post

No comments.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Trackbacks and Pingbacks on this post

No trackbacks.

TrackBack URL