Skip to content

Instantly share code, notes, and snippets.

View xnau's full-sized avatar

Roland Barker xnau

View GitHub Profile
@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' );
<?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
<?php endwhile; // field loop ?>
<?php // we are going to add our new submit button code here
</fieldset>
<?php endwhile; // group loop ?>
<?php // this fieldset is the one we are going to remove
<?php endwhile; // field loop ?>
<div id="submit-button" class="controls">
<?php pdb_field_group_tabs_submit_button( $this ) ?>
</div>
</fieldset>
<?php endwhile; // group loop ?>
<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
<?php
/*
* bootstrap template for signup form
*
* demonstrates a simple dependent selector
*
* the cities available for selection are constrained by the selected state
*
*/
?>
@xnau
xnau / pdb-backend-dynamic-values.php
Last active March 1, 2017 08:02
demonstrates a simple filter for capturing a dynamic value on the admin side in Participants database
<?php
add_action( 'pdb-form_element_build_text-line', 'xnau_place_dynamic_value' );
/**
* sets the value of a dynamic hidden field in the backend
*
* @param object $field
*/
function xnau_place_dynamic_value( $field )
{
/*
@xnau
xnau / pdb-record-backend-user.php
Last active March 1, 2017 08:39
Record the user who created or edited a record in the backend
<?php
add_action( 'pdb-after_submit_add', 'xnau_record_backend_user' );
add_action( 'pdb-after_submit_update', 'xnau_record_backend_user' );
/**
* record the user who created or edited a record in the backend
*
* @param array $record the record data
*/
function xnau_record_backend_user( $record )
{
@xnau
xnau / pdb-html-form-element-example.php
Last active March 14, 2017 20:02
demonstrates using a plugin to add a custom form element that simply prints out any HTML
<?php
/**
* Plugin Name: PDB HTML Form Element
* Description: a general-purpose form element that simply displays HTML
*
*/
class PDb_html_form_element_example {
/**
@xnau
xnau / pdb-single-edit-link.php
Last active March 16, 2017 01:13
demonstrates adding an edit link to s single record page