Last active
March 2, 2018 07:30
-
-
Save xnau/c014e27d036773269d32686c4de8b06a to your computer and use it in GitHub Desktop.
Shows how to set up the use of custom admin capabilities for Participants Database
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
<?php | |
/* | |
Plugin Name: PDb Custom Admin Capabilities | |
Description: Sets up the use of custom admin capabilities for Participants Database | |
*/ | |
add_filter( 'pdb-access_capability', 'xnau_setup_admin_capabilities', 10, 2 ); | |
/** | |
* sets the custom capabilities for use with the plugin | |
* | |
* @param string $capability the default capability for the role | |
* @param string $context the specific context of the request (ignored) | |
* | |
* @return string the capability to test for | |
*/ | |
function xnau_setup_admin_capabilities( $capability, $context ) | |
{ | |
// translate the incoming standard cap to our custom cap | |
switch ( $capability ) { | |
case 'edit_others_posts': // this is for an editor role | |
$capability = 'edit_pdb_records'; // this is the custom cap for editors | |
break; | |
case 'manage_options': // admin role | |
$capability = 'configure_pdb'; // custom cap for admins | |
break; | |
} | |
return $capability; // return the capability to test for | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This gist was created for a tutorial:
Setting Up Custom Access Roles in Participants Database