Template::getRoles() method

Get the role pages that are part of this template

  • This method returns a blank PageArray if roles haven’t yet been loaded into the template.
  • If the roles have previously been loaded as an array, then this method converts that array to a PageArray and returns it.
  • If you make changes to returned roles, make sure to set it back to the template again with setRoles(). It’s preferable to make changes with addRole() and removeRole() methods instead.


// basic usage
$items = $template->getRoles();

// usage with all arguments
$items = $template->getRoles(string $type = 'view');


type (optional)string

Default is 'view', but you may also specify 'edit', 'create' or 'add' to retrieve those.

Return value


of Role objects.


Method can throw exceptions on error:

  • WireException - if given an unknown roles type

Template methods and properties

API reference based on ProcessWire core version 3.0.163

Twitter updates

  • Weekly update – 28 August 2020 – New secure files option defined per-template: More
    28 August 2020
  • ProcessWire 3.0.165 core updates (master and dev branch) and reCAPTCHA for FormBuilder module— More
    21 August 2020
  • What's coming in ProcessWire 3.0.165, plus a brief preview ProCache and FormBuilder versions coming within the next couple of weeks— More
    14 August 2020

Latest news

  • ProcessWire Weekly #330
    In the 330th issue of ProcessWire Weekly we'll take a quick peek at the new release of the FormBuilder module, cover some recent form highlights, and more. Read on!
    Weekly.pw / 5 September 2020
  • ProcessWire 3.0.164 new master version
    This week we’re proud to announce the newest ProcessWire master version 3.0.164. Relative to the previous master version (3.0.148) this version adds a ton of new and useful features and fixes more than 85 issues, with more than 225 commits over a period of 7 months.
    Blog / 7 August 2020
  • Subscribe to weekly ProcessWire news

“ProcessWire is like a breath of fresh air. So powerful yet simple to build with and customise, and web editors love it too.” —Margaret Chatwin, Web developer