Skip to content

Instantly share code, notes, and snippets.

View xnau's full-sized avatar

Roland Barker xnau

View GitHub Profile
@xnau
xnau / random_number_id.php
Last active June 8, 2018 18:03
shows how to replace the normal private ID generation with a 6-digit number
<?php
// filter the private id generation to supply a numeric private ID
add_filter( 'pdb-generate_private_id', 'generate_random_number_id');
function generate_random_number_id( $private_id )
{
// get a 6-digit random number
$numeric_id = rand( 100000, 999999 );
// send it back tot he plugin
return $numeric_id;
}
@xnau
xnau / change_currency_value_display.php
Last active June 8, 2018 20:12
shows how to change the display of a Participants Database field
<?php
/**
* Plugin Name: PDB Customize Currency Display
* Description: replaces a zero value with a custom string
*/
add_filter( 'pdb-before_display_form_element', 'xnau_show_currency_value', 10, 2 );
/**
* replaces a 0 value with a string
*
* @param string $display the display string
@xnau
xnau / pdb-opengraph-headers.php
Last active June 15, 2018 23:09
Demonstrates how to place OpenGraph meta data into a Participants Database single record display page.
<?php
/**
* Plugin Name: PDB Add Facebook/Twitter Meta Tags
* Description: place metadata tags in the header of a single record page
*/
// this will fire just before the end of the page <head> tag
add_action( 'wp_head', 'xnau_place_opengraph_tags', 100 );
/**
* places the meta tags in the page head
@xnau
xnau / pdb-single-opengraph.php
Last active June 17, 2018 04:47
Shows how to set up a custom Participants Database template that only prints opengraph meta tags
<?php
/**
* @name pdb single opengraph template
* @version 0.1
*
* template for printing opengraph meta tags
*
* simplified information on using social media meta tags can be found here:
* https://css-tricks.com/essential-meta-tags-social-media/
*
@xnau
xnau / pdb-auto-unapprove.php
Created June 25, 2018 17:48
Demonstrates how to automatically "unapprove" a record in Participants Database when the user makes changes.
<?php
/**
* Plugin Name: PDB Auto Unapprove
* Description: sets the record approval field to "no" when the user edites their record
*/
add_action( 'pdb-after_submit_update', 'xnau_auto_unapprove' );
/**
* sets the approval field to "no" when a user updates their record
*
* @param array $post the posted data
@xnau
xnau / pdb-list-grid.css
Last active June 27, 2018 04:37
CSS for setting up a grid layout using the Participants Database responsive list display
/*
Stylesheet for setting up a CSS grid layout for the
Participants Database responsive list display
*/
/* this is to hide unneeded elements */
.pdb-list-grid .pdb-field-title,
.pdb-list-grid h5 {
@xnau
xnau / pdb-check-multiple.php
Last active July 10, 2018 19:41
Demonstrates a way to check multiple fields for a match in Participants Database
<?php
/**
* Plugin Name: PDB Multiple Field Match Check
* Description: checks a new Participants Database submission against
* the database for a matching record using multiple fields
* Version: 1.2
*/
add_filter( 'pdb-incoming_record_match', 'xnau_check_for_match', 10, 2 );
/**
@xnau
xnau / pdb-single-opengraph.php
Last active July 18, 2018 20:20
Shows how to set up a template for including meta tags in a Participants Database singe record page when using the Image Expansion add-on
<?php
/**
* @name pdb single opengraph template
* @version 0.1
*
* template for printing opengraph meta tags
*
* this variant is for use with the Participants Database Image Expansion add-on
*
* simplified information on using social media meta tags can be found here:
@xnau
xnau / pdb-single-dual.php
Created September 25, 2018 18:23
Shows how to use a value in the record to determine which fields to show in the Participants Database single record display.
<?php
/*
* shows a single record display based on a value in the record
*/
if ( $this->participant_id ) : ?>
<?php
switch ( $this->participant_values['type'] ) {
case 'player':
@xnau
xnau / pdb-list-multisearch-map.php
Last active September 26, 2018 04:23
Shows how to set up a list template for adding a locations map when using the Participants Database Combo Multisearch plugin
<?php
/*
*
* template for showing a Participants Database list with combo multisearch and a dynamic map
*/
$listmap = new pdbgmap\listmap($this);
global $PDb_Combo_Multi_Search;
$PDb_Combo_Multi_Search->enable();
$combo_search = $PDb_Combo_Multi_Search->get_text_search_value();