1 filter.module filter_get_formats_by_role($role_name)

Retrieves a list of text formats that are allowed for a given role.

Parameters

string $role_name: The user role name to retrieve text formats for.

Return value

An array of text format objects that are allowed for the role, keyed by: the text format ID and ordered by weight.

File

core/modules/filter/filter.module, line 941
Framework for handling the filtering of content.

Code

function filter_get_formats_by_role($role_name) {
  $formats = array();
  foreach (filter_formats() as $format) {
    $roles = filter_get_roles_by_format($format);
    if (in_array($role_name, $roles)) {
      $formats[$format->format] = $format;
    }
  }
  return $formats;
}