# wp_admin_bar_my_account_item()

URL: https://chugunov.pro/api-wordpress/functions/wp_admin_bar_my_account_item/
Проверено на WordPress 6.9, обновлено 06.08.2026.
Источник: независимый русскоязычный справочник chugunov.pro. Не является официальной документацией WordPress.

Тип: функция.
Появился в версии: 3.3.0.

## Сигнатура

```php
wp_admin_bar_my_account_item( WP_Admin_Bar $wp_admin_bar )
```

## Описание

Добавляет пункт «Моя учётная запись».

## Параметры

- `$wp_admin_bar` `WP_Admin_Bar` — обязательный. Экземпляр WP_Admin_Bar.

## Исходный код

Файл: `wp-includes/admin-bar.php:262`

```php
function wp_admin_bar_my_account_item( $wp_admin_bar ) {
	$user_id = get_current_user_id();
	if ( ! $user_id ) {
		return;
	}

	if ( current_user_can( 'read' ) ) {
		$profile_url = get_edit_profile_url( $user_id );
	} elseif ( is_multisite() ) {
		$profile_url = get_dashboard_url( $user_id, 'profile.php' );
	} else {
		$profile_url = false;
	}

	/* translators: %s: Current user's display name. */
	$howdy = sprintf( __( 'Howdy, %s' ), '<span class="display-name">' . wp_get_current_user()->display_name . '</span>' );

	$avatar = get_avatar( $user_id, 26 );
	$wp_admin_bar->add_node(
		array(
			'id'     => 'my-account',
			'parent' => 'top-secondary',
			'title'  => $howdy . $avatar,
			'href'   => $profile_url,
			'meta'   => array(
				'class'      => empty( $avatar ) ? '' : 'with-avatar',
				'menu_title' => wp_strip_all_tags( $howdy ),
				'tabindex'   => ( false !== $profile_url ) ? '' : 0,
			),
		)
	);
}
```

## История изменений

- 3.3.0 — Introduced.

## Связанные

Использует: [`wp_strip_all_tags`](https://chugunov.pro/api-wordpress/functions/wp_strip_all_tags/), [`get_avatar`](https://chugunov.pro/api-wordpress/functions/get_avatar/), [`wp_get_current_user`](https://chugunov.pro/api-wordpress/functions/wp_get_current_user/), [`get_edit_profile_url`](https://chugunov.pro/api-wordpress/functions/get_edit_profile_url/), [`get_dashboard_url`](https://chugunov.pro/api-wordpress/functions/get_dashboard_url/), `WP_Admin_Bar::add_node`, [`current_user_can`](https://chugunov.pro/api-wordpress/functions/current_user_can/), [`__`](https://chugunov.pro/api-wordpress/functions/__/), [`is_multisite`](https://chugunov.pro/api-wordpress/functions/is_multisite/), [`get_current_user_id`](https://chugunov.pro/api-wordpress/functions/get_current_user_id/).

Оригинал в официальной документации: https://developer.wordpress.org/reference/functions/wp_admin_bar_my_account_item/
