From d9e4fc273d76d7f98db0d7f310d6120987c2aa6b Mon Sep 17 00:00:00 2001 From: Felix Arntz Date: Fri, 17 Nov 2017 21:35:51 +0000 Subject: [PATCH] Multisite: Do not show edit links in network users table for users that cannot be edited. Props ocean90. Fixes #42552. Built from https://develop.svn.wordpress.org/trunk@42202 git-svn-id: http://core.svn.wordpress.org/trunk@42032 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- .../includes/class-wp-ms-users-list-table.php | 30 ++++++++++++++----- wp-includes/version.php | 2 +- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/wp-admin/includes/class-wp-ms-users-list-table.php b/wp-admin/includes/class-wp-ms-users-list-table.php index 86af8becbe..cefe693749 100644 --- a/wp-admin/includes/class-wp-ms-users-list-table.php +++ b/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' ) . ''; diff --git a/wp-includes/version.php b/wp-includes/version.php index 029109e4d7..f981e9cd1f 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '5.0-alpha-42201'; +$wp_version = '5.0-alpha-42202'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.