GravityView Capabilities
Related articles:
- Creating a View Editor role
- Creating an Entry Moderator role
- Filtering entries by WordPress User Roles
- Why can’t I edit my View?
⚠️When a new custom user role is created, there’s no need to add any GravityView or Gravity Forms capabilities to it. By default, GravityView allows entry creators to modify their entries, even if this role is similar to a Subscriber.
GravityView Capabilities #
Version 1.15 and higher
GravityView allows you to control user capabilities. We recommend controlling access modify access using the Members plugin.
Full Access
gravityview_full_access– Controls whether the user has access to all GravityView capabilities. Enabling this capability is the same as allowing all of the others.
Settings
gravityview_view_settings– Controls whether plugin settings can be viewed.gravityview_edit_settings– Controls whether plugin settings can be modified.gravityview_uninstall– Controls whether GravityView content can be deleted when the plugin is deleted.gravityview_getting_started– Controls whether the user can read the GravityView Getting Started page.
Entry Capabilities
gravityview_moderate_entries– Controls whether entries can be approved or rejected. If disabled, hides the Approval column in the Entries screen and the “Approve” and “Disapprove” Bulk Edit actions. Required to moderate entries from the front end.gravityview_edit_others_entries– Controls whether the user can edit others’ entries in the GravityView Edit Entry screen.gravityview_delete_others_entries– Controls whether the user can delete others’ entries in the GravityView Edit Entry screen.gravityview_edit_entries– Controls whether the user can use the “Change Entry Creator” functionality or see Edit Entry in the Admin Toolbar. Not Yet Implemented: Control whether the user can edit entries.
Entry Notes Capabilities
Added in GravityView 1.17
gravityview_add_entry_notes– Controls whether entry notes can be added from the front end.gravityview_view_entry_notes– Controls whether entry notes can be viewed from the front end.gravityview_delete_entry_notes– Controls whether entry notes can be deleted from the front end.gravityview_email_entry_notes– Controls whether the user can also send an email (to an email address connected to an entry) while adding a note.
View Capabilities
edit_gravityviews– Controls whether Views can be edited. If disabled, the “Views” menu item is not visible.edit_others_gravityviews– Controls whether Views owned by other users can be edited.publish_gravityviews– Controls whether Views can be published.read_private_gravityviews– Controls whether private Views can be read.delete_gravityviews– Controls whether Views of this post type can be deleted.delete_private_gravityviews– Controls whether private Views can be deleted.delete_published_gravityviews– Controls whether published Views can be deleted.delete_others_gravityviews– Controls whether Views owned by other users can be, can be deleted.edit_private_gravityviews– Controls whether private Views can be edited.edit_published_gravityviews– Controls whether published Views can be edited.copy_gravityviews– Controls whether “Clone View” or “New Draft” capabilities are visible.
Support Capabilities
gravityview_contact_support– Controls whether the user can contact GravityKit’s support via the Support Portgravityview_support_port– Controls whether the GravityView Support Port is visible.
Per-View Capabilities
These are meta capabilities: each one represents an action against a single View rather than something you assign to a role. They will not appear in a role editor such as Members, and adding them to a role has no effect. WordPress resolves them into the primitive capabilities listed under View Capabilities above, based on who authored the View.
edit_gravityview– Controls whether a specific View can be edited.read_gravityview– Controls whether a specific View can be read.delete_gravityview– Controls whether a specific View can be deleted.
Letting a role edit only one View
The primitive capabilities apply to the whole post type, so edit_others_gravityviews grants editing on every View at once. The one per-View distinction WordPress makes on its own is authorship, which separates editing your own Views from editing everyone else’s. Both approaches below build on that.
Warning: since GravityView 3.0, a user without the unfiltered_html capability cannot edit Views at all, regardless of which View capabilities they have been given. The built-in Editor role has unfiltered_html, but a custom role built up from Subscriber does not. On a multisite network the capability is reserved for Super Admins.
Option 1: make the user the View’s author. Give the role edit_gravityviews, edit_published_gravityviews and unfiltered_html, and leave edit_others_gravityviews switched off. That user can then edit any View they authored, and no others. Views do not show an Author field in the editor by default, so add one:
add_filter( 'gravityview_post_type_support', function ( $supports ) {
$supports[] = 'author';
return $supports;
} );Option 2: grant one specific View. To tie the permission to a single View no matter who authored it, filter user_has_cap and grant the primitive capabilities only for that one pairing of user and View. Replace 45 with the user ID and 123 with the View ID:
/**
* Allows one user to edit one specific View.
*
* The per-View meta capability (edit_gravityview) is resolved by WordPress into the
* primitive capabilities granted below, so those are what need to be set.
*
* @param array $caps All capabilities the user currently has.
* @param array $required The capabilities required for this check.
* @param array $args [0] requested capability, [1] user ID, [2] object ID.
*
* @return array
*/
add_filter( 'user_has_cap', function ( $caps, $required, $args ) {
$user_id = 45; // The user who should get access.
$view_id = 123; // The View they should be able to edit.
// Only act on an edit check against a specific post.
if ( 'edit_post' !== ( $args[0] ?? '' ) ) {
return $caps;
}
// Bail unless this is the exact user and View pairing.
if ( (int) ( $args[1] ?? 0 ) !== $user_id || (int) ( $args[2] ?? 0 ) !== $view_id ) {
return $caps;
}
$caps['edit_others_gravityviews'] = true;
$caps['edit_published_gravityviews'] = true;
return $caps;
}, 10, 3 );Read here how to add these code samples to your website: Where to put code samples.
Roles #
When GravityView is activated, the following capabilities are automatically added to each role:
Administrator
Summary: Full access to settings, ability to contact support, and everything else
gravityview_full_accessgravityview_view_settingsgravityview_edit_settingsgravityview_uninstallgravityview_contact_support- … as well as the capabilities below
Editor
Summary: Edit, publish, and delete everyone’s stuff
edit_others_gravityviewsread_private_gravityviewsdelete_private_gravityviewsdelete_others_gravityviewsedit_private_gravityviewspublish_gravityviewsdelete_published_gravityviewsedit_published_gravityviewsgravityview_edit_others_entriesgravityview_moderate_entriesgravityview_delete_others_entriesgravityview_add_entry_notesgravityview_view_entry_notesgravityview_delete_entry_notesgravityview_email_entry_notes- … as well as the capabilities below
Author
Summary: Edit, publish and delete your own stuff
gravityview_edit_entriesgravityview_edit_entrygravityview_edit_form_entriesgravityview_delete_entriesgravityview_delete_entry- … as well as the capabilities below
Contributor
Summary: Edit and delete drafts but not publish
edit_gravityviewsdelete_gravityviewsgravityview_support_port- … as well as the capabilities below
Subscriber
Summary: Read-only
gravityview_view_entriesgravityview_view_others_entriesread– If your Views are not showing up for a Subscriber, make sure you have this generic WordPress capability enabled