Last active
November 16, 2022 23:49
-
-
Save zackkatz/e70a039a420d26a063296f6010c72786 to your computer and use it in GitHub Desktop.
GravityImport - Prevent users with the role "editor" from importing entries
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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