Last active
December 13, 2017 19:16
-
-
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
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 | |
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