Skip to content

Instantly share code, notes, and snippets.

@xnau
Last active December 13, 2017 19:16
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/f53e3d584b762b6d18563ff477b6905c to your computer and use it in GitHub Desktop.
Save xnau/f53e3d584b762b6d18563ff477b6905c to your computer and use it in GitHub Desktop.
Demonstrates the use of a filter to allow Participants Database editors to delete records
<?php
add_filter( 'pdb-access_capability', 'allow_editor_list_delete', 10, 2 );
/**
* alters access privileges
*
* @see https://codex.wordpress.org/Roles_and_Capabilities
*
* @param string $cap current WP capability for the privilege
* @param string $context the privilege requested
* @return string the WP capability to use for the privilege
*/
function allow_editor_list_delete( $cap, $context )
{
switch ( $context ) {
case 'delete participants'; // this is the particular privilege we want to change
$cap = 'edit_others_posts'; // this is the WP capability the the user must have
break;
}
return $cap;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment