get_editable_roles()
Проверено на WordPress 6.9, обновлено Источник: WordPress Developer Resources.
Сигнатура
get_editable_roles(): array[]
Описание
Простая функция, основное назначение которой — позволить фильтровать список ролей в объекте $wp_roles, чтобы плагины могли убирать неподходящие роли в зависимости от ситуации или пользователя, вносящего изменения.
В частности, потому что без фильтрации любой, кто обладает правом доступа edit_users, может назначать другим роль администратора, даже будучи всего лишь редактором или автором. Этот фильтр позволяет администраторам делегировать управление пользователями.
Оригинал (английский)
Simple function whose main purpose is to allow filtering of the list of roles in the $wp_roles object so that plugins can remove inappropriate ones depending on the situation or user making edits.
Specifically because without filtering anyone with the edit_users capability can edit others to be administrators, even if they are only editors or authors. This filter allows admins to delegate user management.
Возвращаемое значение
array[]
Исходный код
wp-admin/includes/user.php:268
function get_editable_roles() {
$all_roles = wp_roles()->roles;
/**
* Filters the list of editable roles.
*
* @since 2.8.0
*
* @param array[] $all_roles Array of arrays containing role information.
*/
$editable_roles = apply_filters( 'editable_roles', $all_roles );
return $editable_roles;
}
История изменений
| Версия | Описание |
|---|---|
| 2.8.0 | Introduced. |

