Skip to content

Instantly share code, notes, and snippets.

@xnau
Last active October 28, 2017 20:46
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 xnau/53de66190ec8430d87cc9e06acf310f7 to your computer and use it in GitHub Desktop.
Save xnau/53de66190ec8430d87cc9e06acf310f7 to your computer and use it in GitHub Desktop.
Demonstrates how to alter a specific access capability in Participants Database
<?php
add_filter( 'pdb-access_capability', 'set_pdb_access_controls', 10, 2 );
/*
* @param string $cap the current capability level that gives access to the function named in $context
* @param string $context the specific action that is being tested
* @return string the capability that is allowed to access the function named in $context
*/
function set_pdb_access_controls( $cap, $context )
{
// set the access capability for a specific action
switch ( $context ) {
case 'delete participants':
$cap = 'edit_others_posts'; // typical cap for WP Editors
break;
}
return $cap;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment