Skip to content

Instantly share code, notes, and snippets.

@mannieschumpert
Last active December 30, 2020 14:51
Show Gist options
  • Save mannieschumpert/7188426 to your computer and use it in GitHub Desktop.
Save mannieschumpert/7188426 to your computer and use it in GitHub Desktop.
When using Gravity Forms on a client project, you might want the client to be able to view and manipulate form entries, without giving them administrator access. The user_has_cap filter allows us to add capabilities without changing the role in the database. This gist allows users with the editor role to view and manipulate form entries.
<?php
/**
* Add Gravity Forms capabilities
*/
add_filter('user_has_cap',
function( $caps ){
if (! empty( $caps['edit_pages'] ) ) { // user has edit capabilities
$caps['gravityforms_delete_entries'] = true;
$caps['gravityforms_edit_entries'] = true;
$caps['gravityforms_edit_entry_notes'] = true;
$caps['gravityforms_view_entries'] = true;
$caps['gravityforms_view_entry_notes'] = true;
}
return $caps;
});
@mannieschumpert
Copy link
Author

Huh, I missed this comment. You're totally right, I'm not sure how I missed that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment