Each plugin has a special code name (called a prefix) that you’ll use to control what plugin you are customizing. Here’s a quick list of those prefixes to help you out:
Plugin | Prefix | Additional filters |
---|---|---|
Database Cleaner | dbclnr | |
AI Engine | mwai | |
Meow Gallery | mgl | |
Meow Lightbox | mwl | |
Media File Renamer | mfrh | |
Social Engine | sclegn | _allow_moderation |
Media Cleaner | wpmc |
We will be using two filters : _allow_setup
and _allow_usage
.
Setting the Scene with add_filter
in functions.php
Want to customize who can do what? It’s all about tweaking the add_filter
function in your theme’s functions.php
file (or in a snippet plugin). Let’s take the Database Cleaner plugin as an example and set up a few different roles:
// 🎩 Editors and Admins, welcome to the Database Cleaner settings.
add_filter( 'dbclnr_allow_setup', function() {
$editors_admins = current_user_can( 'editor' ) || current_user_can( 'administrator' );
return $editors_admins;
} );
// ✍️ Authors can use all the features in Database Cleaner.
add_filter( 'dbclnr_allow_usage', function() {
return current_user_can( 'author' );
} );
Feel free to mix and match the roles and plugin prefixes to fit your needs. If you’ve got custom roles, just drop them into the mix like so:
// Custom role "content_manager" gets access to Meow Gallery
add_filter( 'mgl_allow_usage', function() {
return current_user_can( 'content_manager' );
} );
You can customize this code how you want, if you use third party plugins for role management, you can use them here also.