Skip to content

Instantly share code, notes, and snippets.

View xnau's full-sized avatar

Roland Barker xnau

View GitHub Profile
@xnau
xnau / pdb-update_notify.php
Created November 7, 2016 02:37
Notify the user when their record is updated by an admin
<?php
/*
Plugin Name: Participants Database Update Notify
Description: Notifies the user when their record is updated
*/
/*
* before the update is stored, send an email notification to the participant
*/
add_filter( 'pdb-before_submit_update', 'pdb_send_record_update_notification' );
@xnau
xnau / pdb-email_on_approval.php
Created November 7, 2016 02:55
Sends the Participants Database welcome email when a record is approved
<?php
/*
Plugin Name: Participants Database Send Welcome On Approval
Description: Sends the welcome email when a record is approved.
*/
/*
* check the new record data before the record is updated
*/
add_filter( 'pdb-before_submit_update', 'pdb_send_record_update_notification' );
@xnau
xnau / pdb_custom_form_elment_example.php
Last active February 10, 2022 19:05
example of creating a Participants Database Custom Form Element
<?php
/**
* Plugin Name: PDB Array Form Element
* Description: a demonstration of the basic technique for creating a custom form element in Participants Database
*
*/
add_filter( 'pdb-set_form_element_types', 'my_array_register_element' );
add_action( 'pdb-form_element_build_array','my_array_element_building_function' );
add_filter( 'pdb-before_display_form_element','my_array_element_value_display_function', 10, 2 );
@xnau
xnau / pdb_external_links.php
Last active November 29, 2018 18:30
Making Participants Database list links to external sites open in a new tab
@xnau
xnau / pdb-list-edit-link.php
Last active December 31, 2020 18:18
Participants Database Default List Template with Edit Record Link
<?php
/*
* bootstrap template for signup form
*
* demonstrates a simple dependent selector
*
* the cities available for selection are constrained by the selected state
*
*/
?>
@xnau
xnau / city_selector.js
Last active January 16, 2019 03:22
Just the javascript from the state/city selector example
<script>
jQuery(function($){
// name of the parent field
var parent = 'state';
// name of the child field
var child = 'city';
// defines the parent selector dropdown
var parent_select = $('select[name='+parent+']');
<?php
/**
* validates a field submission for a valid URL
*
* @param PDb_Validating_Field $field
* @return null
*/
function xnau_check_valid_url( $field )
{
// first, check to see if it is the field we want to validate
<?php
/**
* adds a custom validation error message
*
* @param array $error_messages
* @return array
*/
function xnau_add_url_validation_error_message( $error_messages )
{
// add our message with a placeholder for the field name
<div class="wrap <?php echo $this->wrap_class ?>">
<?php
if (!empty($this->participant_id)) :
// output any validation errors
$this->print_errors();
?>
<?php
// print the form header