Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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.
* Add Gravity Forms capabilities
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;

This comment has been minimized.

Copy link

commented Mar 20, 2014

I suppose the code should read if ( ... ) { ... }, right? There are some curly braces missing, otherwise you would grant the first capability (i.e., delete_entries) only if the user already has edit capabilities, however, all the other caps are always granted.
I just forked the gist and corrected this, and also refactored the logic a bit.


This comment has been minimized.

Copy link
Owner Author

commented May 15, 2014

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
You can’t perform that action at this time.