# populate_roles()

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

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

## Сигнатура

```php
populate_roles()
```

## Описание

Выполняет создание ролей WordPress для различных версий WordPress.

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

Файл: `wp-admin/includes/schema.php:719`

```php
function populate_roles() {
	$wp_roles = wp_roles();

	// Disable role updates to the database while populating roles.
	$original_use_db  = $wp_roles->use_db;
	$wp_roles->use_db = false;

	// Populate roles
	populate_roles_160();
	populate_roles_210();
	populate_roles_230();
	populate_roles_250();
	populate_roles_260();
	populate_roles_270();
	populate_roles_280();
	populate_roles_300();

	// Save the updated roles to the database.
	if ( $original_use_db ) {
		update_option( $wp_roles->role_key, $wp_roles->roles, true );
	}

	// Restore original value for writing to database.
	$wp_roles->use_db = $original_use_db;
}
```

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

- 2.0.0 — Introduced.

## Связанные

Использует: [`wp_roles`](https://chugunov.pro/api-wordpress/functions/wp_roles/), [`WP_Roles`](https://chugunov.pro/api-wordpress/functions/wp_roles/), [`populate_roles_160`](https://chugunov.pro/api-wordpress/functions/populate_roles_160/), [`populate_roles_210`](https://chugunov.pro/api-wordpress/functions/populate_roles_210/), [`populate_roles_230`](https://chugunov.pro/api-wordpress/functions/populate_roles_230/), [`populate_roles_250`](https://chugunov.pro/api-wordpress/functions/populate_roles_250/), [`populate_roles_260`](https://chugunov.pro/api-wordpress/functions/populate_roles_260/), [`populate_roles_270`](https://chugunov.pro/api-wordpress/functions/populate_roles_270/), [`populate_roles_280`](https://chugunov.pro/api-wordpress/functions/populate_roles_280/), [`populate_roles_300`](https://chugunov.pro/api-wordpress/functions/populate_roles_300/), [`update_option`](https://chugunov.pro/api-wordpress/functions/update_option/).
Используется в: [`wp_initialize_site`](https://chugunov.pro/api-wordpress/functions/wp_initialize_site/), [`wp_install`](https://chugunov.pro/api-wordpress/functions/wp_install/), [`install_blog`](https://chugunov.pro/api-wordpress/functions/install_blog/).

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