From b424eecd0b255537ec3b7d87f8096d8158f92aae Mon Sep 17 00:00:00 2001 From: Felix Arntz Date: Fri, 17 Nov 2017 21:34:01 +0000 Subject: [PATCH] Multisite: Do not show edit links in network users table for users that cannot be edited. Props ocean90. Fixes #42552. git-svn-id: https://develop.svn.wordpress.org/trunk@42202 602fd350-edb4-49c9-b593-d223f7449a82 --- .../includes/class-wp-ms-users-list-table.php | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/src/wp-admin/includes/class-wp-ms-users-list-table.php b/src/wp-admin/includes/class-wp-ms-users-list-table.php index 86af8becbe..cefe693749 100644 --- a/src/wp-admin/includes/class-wp-ms-users-list-table.php +++ b/src/wp-admin/includes/class-wp-ms-users-list-table.php @@ -233,16 +233,27 @@ class WP_MS_Users_List_Table extends WP_List_Table { public function column_username( $user ) { $super_admins = get_super_admins(); $avatar = get_avatar( $user->user_email, 32 ); - $edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user->ID ) ) ); echo $avatar; - ?>user_login; ?>user_login, $super_admins ) ) { - echo ' — ' . __( 'Super Admin' ); + if ( current_user_can( 'edit_user', $user->ID ) ) { + $edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user->ID ) ) ); + $edit = "{$user->user_login}"; + } else { + $edit = $user->user_login; } - ?> - + + user_login, $super_admins ) ) { + echo ' — ' . __( 'Super Admin' ); + } + ?> + + ID ) ) ); $actions = array(); - $actions['edit'] = '' . __( 'Edit' ) . ''; + + if ( current_user_can( 'edit_user', $user->ID ) ) { + $edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user->ID ) ) ); + $actions['edit'] = '' . __( 'Edit' ) . ''; + } if ( current_user_can( 'delete_user', $user->ID ) && ! in_array( $user->user_login, $super_admins ) ) { $actions['delete'] = '' . __( 'Delete' ) . '';