Skip to content

Instantly share code, notes, and snippets.

@zackkatz
Last active November 16, 2022 23:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zackkatz/e70a039a420d26a063296f6010c72786 to your computer and use it in GitHub Desktop.
Save zackkatz/e70a039a420d26a063296f6010c72786 to your computer and use it in GitHub Desktop.
GravityImport - Prevent users with the role "editor" from importing entries
/**
* Remove the ability of a user to import entries based on their role.
*
* @param array $caps Array of capabilities required to display the UI.
*
* @return array
*/
add_filter( 'gravityview/import/capabilities', function ( $caps ) {
// REPLACE THIS with the role you want to exclude from importing entries.
$role = 'editor';
$user = wp_get_current_user();
if ( ! $user || ! $user->exists() ) {
return [];
}
if ( in_array( $role, $user->roles, true ) ) {
return [];
}
return $caps;
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment