get_editable_roles

The timeline below displays how wordpress function get_editable_roles has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 5.1

/**
 * Fetch a filtered list of user roles that the current user is
 * allowed to edit.
 *
 * 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.
 *
 * @since 2.8.0
 *
 * @return array[] Array of arrays containing role information.
 */
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;
}

WordPress Version: 4.6

/**
 * Fetch a filtered list of user roles that the current user is
 * allowed to edit.
 *
 * Simple function who's 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.
 *
 * @since 2.8.0
 *
 * @return array
 */
function get_editable_roles()
{
    $all_roles = wp_roles()->roles;
    /**
     * Filters the list of editable roles.
     *
     * @since 2.8.0
     *
     * @param array $all_roles List of roles.
     */
    $editable_roles = apply_filters('editable_roles', $all_roles);
    return $editable_roles;
}

WordPress Version: 4.3

/**
 * Fetch a filtered list of user roles that the current user is
 * allowed to edit.
 *
 * Simple function who's 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.
 *
 * @since 2.8.0
 *
 * @return array
 */
function get_editable_roles()
{
    $all_roles = wp_roles()->roles;
    /**
     * Filter the list of editable roles.
     *
     * @since 2.8.0
     *
     * @param array $all_roles List of roles.
     */
    $editable_roles = apply_filters('editable_roles', $all_roles);
    return $editable_roles;
}

WordPress Version: 4.1

/**
 * Fetch a filtered list of user roles that the current user is
 * allowed to edit.
 *
 * Simple function who's 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.
 *
 * @since 2.8.0
 *
 * @return array
 */
function get_editable_roles()
{
    global $wp_roles;
    $all_roles = $wp_roles->roles;
    /**
     * Filter the list of editable roles.
     *
     * @since 2.8.0
     *
     * @param array $all_roles List of roles.
     */
    $editable_roles = apply_filters('editable_roles', $all_roles);
    return $editable_roles;
}

WordPress Version: 3.9

/**
 * Fetch a filtered list of user roles that the current user is
 * allowed to edit.
 *
 * Simple function who's 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.
 *
 * @since 2.8.0
 *
 * @return unknown
 */
function get_editable_roles()
{
    global $wp_roles;
    $all_roles = $wp_roles->roles;
    /**
     * Filter the list of editable roles.
     *
     * @since 2.8.0
     *
     * @param array $all_roles List of roles.
     */
    $editable_roles = apply_filters('editable_roles', $all_roles);
    return $editable_roles;
}

WordPress Version: 3.8

/**
 * Fetch a filtered list of user roles that the current user is
 * allowed to edit.
 *
 * Simple function who's 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.
 *
 * @since 2.8
 *
 * @return unknown
 */
function get_editable_roles()
{
    global $wp_roles;
    $all_roles = $wp_roles->roles;
    /**
     * Filter the list of editable roles.
     *
     * @since 2.8.0
     *
     * @param array $all_roles List of roles.
     */
    $editable_roles = apply_filters('editable_roles', $all_roles);
    return $editable_roles;
}

WordPress Version: 3.7

/**
 * Fetch a filtered list of user roles that the current user is
 * allowed to edit.
 *
 * Simple function who's 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.
 *
 * @since 2.8
 *
 * @return unknown
 */
function get_editable_roles()
{
    global $wp_roles;
    $all_roles = $wp_roles->roles;
    $editable_roles = apply_filters('editable_roles', $all_roles);
    return $editable_roles;
}