WP_MS_Users_List_Table::column_username() WordPress Method

The WP_MS_Users_List_Table::column_username() method is used to display the username for each user in a multisite installation. This is useful for managing a large number of users, as it allows you to quickly see which username belongs to which user.

WP_MS_Users_List_Table::column_username( WP_User $user ) #

Handles the username column output.


Parameters

$user

(WP_User)(Required)The current WP_User object.


Top ↑

Source

File: wp-admin/includes/class-wp-ms-users-list-table.php

	public function column_username( $user ) {
		$super_admins = get_super_admins();
		$avatar       = get_avatar( $user->user_email, 32 );

		echo $avatar;

		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      = "<a href=\"{$edit_link}\">{$user->user_login}</a>";
		} else {
			$edit = $user->user_login;
		}

		?>
		<strong>
			<?php
			echo $edit;

			if ( in_array( $user->user_login, $super_admins, true ) ) {
				echo ' &mdash; ' . __( 'Super Admin' );
			}
			?>
		</strong>
		<?php
	}


Top ↑

Changelog

Changelog
VersionDescription
4.3.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.