Skip to content

Instantly share code, notes, and snippets.

@designbuildtest
Last active December 1, 2022 18:13
Show Gist options
  • Save designbuildtest/486307a8526ef05bc5bf to your computer and use it in GitHub Desktop.
Save designbuildtest/486307a8526ef05bc5bf to your computer and use it in GitHub Desktop.
Gravity Forms capabilities
function myplugin_add_remove_theme_caps() {
$role = get_role( 'client' );
// This only works, because it accesses the class instance.
// Would allow the author to edit others' posts for current theme only
$role->remove_cap( 'gravityforms_export_entries' );
$role->add_cap( 'gravityforms_export_entries' );
gform_full_access
gravityforms_view_entries
gravityforms_view_entry_notes
gravityforms_edit_entries
gravityforms_edit_entry_notes
gravityforms_delete_entries
gravityforms_export_entries
}
add_action( 'admin_init', 'myplugin_add_remove_theme_caps' );
function myplugin_filter_gform_caps( $caps ) {
if ( ! current_user_can( 'manage_options' ) ) {
if ( current_user_can( 'gform_full_access' ) ) {
$user = wp_get_current_user();
$user->remove_cap('gform_full_access');
}
return '';
} else {
return $caps;
}
}
add_filter( 'gform_cap_full_access', 'myplugin_filter_gform_caps' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment