Skip to content

Instantly share code, notes, and snippets.

View xnau's full-sized avatar

Roland Barker xnau

View GitHub Profile
@xnau
xnau / pdb-default-date.php
Last active February 8, 2021 18:28
Shows how to set the default date for a specific date field in Participants Database
<?php
/**
* Plugin Name: PDB Default Date
* Description: sets the default date for a specific date field
*/
add_action( 'pdb-before_display_form_input', 'xnau_set_default_date' );
/**
@xnau
xnau / pdb-log_list-single-link.php
Last active November 3, 2020 19:38
Shows how to include a link to the single record in a Participants Database Participant Log global log list.
@xnau
xnau / pdb-log_list-edit-link.php
Last active June 29, 2021 22:29
Shows how to add a record edit link to a Participants Database Participant Log Global Log List template.
@xnau
xnau / pdb-signup-limit.php
Last active October 6, 2020 18:54
Shows how to set up a Participants Database signup form that limits the number of signups
<?php
/**
*
* signup form that limits the number of signups
*
*/
// set the maximum number of signups
$limit = 100;
@xnau
xnau / pdb-single-option-value-optgroup.php
Last active September 21, 2020 20:04
Shows how to find the optgroup of a field value in a Participants Database custom template.
<?php
$record = new PDb_Template( $this );
// name of the field you're interested in
$field = 'interests';
// get the array of defined options
$option_list = $record->get_field_prop( $field, 'options' );
// assume the title is blank at first
@xnau
xnau / pdd-record-frontend-profile-tabs.php
Last active September 16, 2020 00:24
Shows how to set up a Participants Database WP Profile template that uses a tabbed interface.
<?php
/**
* shows a WP user profile edit form with Participants Database fields in a tabbed interface
*
*/
global $PDb_WP_Users, $PDb_Frontend_Profile, $post, $wp;
/** @var \pdbwpu\Plugin $PDb_WP_Users */
/** @var \pdbwpu\Frontend_Profile $PDb_Frontend_Profile */
$profileuser = $PDb_Frontend_Profile->this_user();
@xnau
xnau / pdb-record_page_title.php
Last active April 24, 2021 13:41
Shows how to set the page title according to the Participants Database record data.
<?php
/**
* Plugin Name: PDB Record Page Title
* Description: uses data from a Participants Database record to set the page title
*
* This plugin uses one or more fields from a participants database record to set
* the title of the page.
*/
class pdb_record_page_title {
@xnau
xnau / pdb-email-html-wrap.php
Last active September 5, 2020 18:28
Shows how to wrap an outgoing Participants Database email with an HTML framework
<?php
/*
* Plugin Name: PDb HTML Email Wrapper
* Description: Adds a structural HTML wrapper to outgoing Participants Database emails.
*/
class pdb_email_html_wrapper {
/**
*
@xnau
xnau / pdb-shortcode-notify.php
Last active September 3, 2020 21:30
Shows how to set up a custom "shortcode present" notification for Participants Database
<?php
/*
* Plugin Name: PDb Shortcode Placement Notification
* Description: Tells the Participants Database plugin that a shortcode is present on the page.
*/
add_filter( 'pdb-shortcode_in_content', 'xnau_notify_shortcode_present', 10, 2 );
/**
* tells the plugin that a shortcode is present
*
@xnau
xnau / pdb-activate-shortcode.php
Created August 22, 2020 02:49
Demonstrates how to let Participants Database know there is a shortcode on a page (see comments for full explanation)
// check for a specific post ID, then fire the action if it matches
add_action( 'wp', function () {
global $post;
if ( $post->ID == 9627 ) {
do_action( 'pdb-shortcode_present');
}
});