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 Sort By Month | |
* Description: Demonstrates how to set up an arbitrary list sort in Participants Database | |
*/ | |
/* | |
* Important: this assumes that the column you want to put the arbitrary sort on is already | |
* present in the sort as defined in the shortcode. For instance, in this example, the shortcode | |
* should have the sort set up like this: [pdb_list orderby="month" order="ASC"] then that sort | |
* gets replaced by the one we are setting up in this filter. |
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_action( 'pdb-after_submit_update', 'xnau_record_last_user' ); | |
/** | |
* record the user who created or edited a record in the backend | |
* | |
* @see https://codex.wordpress.org/Function_Reference/wp_get_current_user | |
* | |
* @param array $record the record data | |
*/ | |
function xnau_record_last_user( $record ) |
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 | |
// if the record is not approved, they cannot edit the record. | |
// you can easily adapt this to any other checkbox field so you can use that field to prevent editing | |
add_filter( 'pdb-check_submission', function() { | |
if ( !is_admin() && $_POST['action'] === 'update' ) { | |
$record = Participants_Db::get_participant( $_POST['id']); | |
// if the field has a value of "yes" allow editing | |
// if it is any other value, editing will not be allowed | |
return $record['approved'] === 'yes'; | |
} |
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', '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 |
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 | |
/* | |
this template demonstrates how to set up a simple search that only searches on a single field: city | |
to change which field is searched on, look at line 50, change the "value" of that hidden field | |
*/ | |
?> | |
<div class="wrap <?php echo $this->wrap_class ?>" id="<?php echo $this->list_anchor ?>"> |
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 Audio Element | |
* Description: Demonstrates how to show an uploaded audio file in an audio element | |
* | |
*/ | |
add_filter( 'pdb-before_display_form_element','pdb_audio_element_display_function', 10, 2); | |
/** | |
* displays the audio element |
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( 'pdbcptet-recipient_tags', 'xnau_filter_recipients' ); | |
/** | |
* filters the recipient list | |
* | |
* @param array $tag_list all the tags and their values | |
* @return array | |
*/ | |
function xnau_filter_recipients( $tag_list ) | |
{ |
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_action( 'pdbmps-status_change_to_past_due', 'xnau_unapprove_record', 10, 2 ); | |
function xnau_unapprove_record ( $status, $data ) | |
{ | |
// this is so we can access a function in the plugin | |
global $PDb_Member_Payments; | |
// now set the record to not approved (2nd argument) | |
$PDb_Member_Payments->approve_record( $data['id'], false ); | |
} |
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 | |
/* | |
* first, check for the value that determines what kind of | |
* record edit form to show | |
*/ | |
$type = $this->participant_values['type']; | |
/* | |
* now, show the record edit form for that type | |
*/ |
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 |