Skip to content

Instantly share code, notes, and snippets.

View xnau's full-sized avatar

Roland Barker xnau

View GitHub Profile
@xnau
xnau / pdb-list-special.php
Last active September 12, 2017 19:12
Demonstrates how to use the PDb_Template class in a custom list template for Participants Database
<?php
/*
template for participants list shortcode output
this template demonstrates a "table-less" reponsive layout for the list of records
using the PDb_Template class for each record
*/
?>
@xnau
xnau / pdb-list-detail-link.php
Created September 23, 2017 18:21
Demonstrates how to add the detail link to several fields in the Participants Database list display
@xnau
xnau / set_private_id_length.php
Last active September 30, 2017 18:54
shows how to change the Participants Database private id length
<?php
/**
* Plugin Name: Participants Database Set Private ID Length
* Description: sets a custom length for the private ID
*/
// set the private ID length to 9
add_filter( 'pdb-private_id_length', function ( $length ) { return 9; } );
@xnau
xnau / pdb-record-last-user.php
Last active October 14, 2017 18:30
Shows how to record the user ID of the person editing a Participants Database record
<?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 )
@xnau
xnau / pdb-prevent-unapproved-record-edit.php
Created October 14, 2017 18:41
shows how to use the "approved" field in a Participants Database record to prevent a record from being edited
<?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';
}
@xnau
xnau / pdb-access_filter.php
Last active October 28, 2017 20:46
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
@xnau
xnau / pdb-list-single-search.php
Created November 2, 2017 20:07
Demonstrates how to set up a Participants Database list search that only searches on a single field
<?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 ?>">
@xnau
xnau / pdb-single-gmap.php
Last active November 3, 2017 18:09
Demontrates a single record template for Participants Database that includes a location map for the listing
<?php
/*
* template for showing a google map in a single record template
*
*/
/*
* this is the name of the group the address fields are in
*
* change this to match the name of the group that contains your address fields
*/
@xnau
xnau / pdb-audio-element.php
Created November 19, 2017 20:05
Demonstrates how to show a uploaded audio file in an audio element
<?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
@xnau
xnau / pdb-recipient-list-filter.php
Last active November 30, 2017 03:04
Demonstrates the use of a filter to set up a contact list dropdown in Participants Database Email Extension Kit
<?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 )
{