The permissions
argument is useful for restricting access to certain fields or sections that require a specified user role. For example, if the options panel is set via page_permissions
to allow users with an editor role or higher to view and set options, but you’d prefer some options or sections be available only to administrators, the permissions argument makes this possible.
In the above scenario, the line 'permissions' => 'manage_options'
would be added to either the sections array to control an entire section, or the field array to control a specific field. The permissions argument accepts any capability name.
NOTES:
- The WordPress documentation strongly recommends NOT using role names (administrator, editor, etc.) in place of capability names as they are not guaranteed to work correctly.
- The
permissions
argument cannot be used with the following fields, as they do not accept or save data:sections
,info
,divide
, andraw
.