Skip to content

Instantly share code, notes, and snippets.

View xnau's full-sized avatar

Roland Barker xnau

View GitHub Profile
@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-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-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-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-prevent-php-clock-sync.php
Last active June 3, 2018 20:29
shows how to disable Participants Database synchronizing the php timezone with the WordPress timezone
<?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 21:32
Shows how to send a Participants Database private link by matching 2 or more fields
@xnau
xnau / pdb-limit-signups.php
Last active May 22, 2018 18:39
Shows how to limit the number of Participants Database signups
<?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 19:04
Demonstrates how to show decimal numbers using comma as the separator
<?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 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-generate-member-id.php
Last active October 10, 2023 07:00
Demonstrates a way to generate and provide a unique ID for new signups and new records in Participants Database
<?php
/**
* Plugin Name: PDB Generate Member ID
* Description: provides a unique ID for new signups and new records in Participants Database
* Version: 2.2
*/
class pdb_generate_member_id {
/**