Skip to content

Instantly share code, notes, and snippets.

Avatar

Roland Barker xnau

View GitHub Profile
@xnau
xnau / pdb-auto-unapprove.php
Created Jun 25, 2018
Demonstrates how to automatically "unapprove" a record in Participants Database when the user makes changes.
View pdb-auto-unapprove.php
<?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-single-opengraph.php
Last active Jul 18, 2018
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
View pdb-single-opengraph.php
<?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-opengraph.php
Last active Jun 17, 2018
Shows how to set up a custom Participants Database template that only prints opengraph meta tags
View pdb-single-opengraph.php
<?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-opengraph-headers.php
Last active Jun 15, 2018
Demonstrates how to place OpenGraph meta data into a Participants Database single record display page.
View pdb-opengraph-headers.php
<?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-prevent-php-clock-sync.php
Last active Jun 3, 2018
shows how to disable Participants Database synchronizing the php timezone with the WordPress timezone
View pdb-prevent-php-clock-sync.php
<?php
/**
* Plugin Name: PDB Defeat Timezone Sync
* Description: disables Participants Database synchronizing the php timezone with the WordPress timezone
*/
add_filter( 'pdb-php_timezone_sync', function () { return false; } );
@xnau
xnau / pdb-custom-link-recovery.php
Created May 28, 2018
Shows how to send a Participants Database private link by matching 2 or more fields
View pdb-custom-link-recovery.php
@xnau
xnau / pdb-limit-signups.php
Last active May 22, 2018
Shows how to limit the number of Participants Database signups
View pdb-limit-signups.php
<?php
/**
* Plugin Name: PDB Limit Signups
* Description: Adds a count of the number of Participants Database signups, and prevents new signups
* once a number of registrations has been reached
*/
add_filter( 'pdb-signup_shortcode_output', 'xnau_limit_signups' );
/**
* adds a display of the number of signups and prevents signups once a limit is reached
*
@xnau
xnau / pdb-comma-decimal-display.php
Created May 18, 2018
Demonstrates how to show decimal numbers using comma as the separator
View pdb-comma-decimal-display.php
<?php
/**
* Plugin Name: PDB Comma Decimal Separator Display
* Description: alters the display of decimal numbers to use comma as the decimal separator, and point as the thousands separator
*/
add_filter('pdb-before_display_form_element', 'xnau_show_comma_decimals', 10, 2 );
function xnau_show_comma_decimals( $display, $field )
{
// we are only modifying these form element types
if ( $field->form_element === 'decimal' || $field->form_element === 'currency' ) {
@xnau
xnau / change_currency_value_display.php
Last active Jun 8, 2018
shows how to change the display of a Participants Database field
View change_currency_value_display.php
<?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-generate-member-id.php
Last active Jan 10, 2021
Demonstrates a way to provide a unique ID for new signups and new records in Participants Database
View pdb-generate-member-id.php
<?php
/**
* Plugin Name: PDB Generate Member ID
* Description: provides a unique ID for new signups and new records in Participants Database
* Version: 2.0
*/
class pdb_generate_member_id {
/**