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
Last active December 4, 2017 04:40
Shows how to trigger an automatic unapproval when the account goes past due in Participants Database Member Payments
<?php
add_action( 'pdbmps-status_change_to_past_due', 'xnau_unapprove_record', 10, 2 );
function xnau_unapprove_record ( $status, $data )
{
// this is so we can access a function in the plugin
global $PDb_Member_Payments;
// now set the record to not approved (2nd argument)
$PDb_Member_Payments->approve_record( $data['id'], false );
}
@xnau
xnau / pdb-allow-editor-delete.php
Last active December 13, 2017 19:16
Demonstrates the use of a filter to allow Participants Database editors to delete records
<?php
add_filter( 'pdb-access_capability', 'allow_editor_list_delete', 10, 2 );
/**
* alters access privileges
*
* @see https://codex.wordpress.org/Roles_and_Capabilities
*
* @param string $cap current WP capability for the privilege
* @param string $context the privilege requested
* @return string the WP capability to use for the privilege
@xnau
xnau / pdb-search-detailed.php
Created December 22, 2017 19:08
A "detailed" template for the Participants Database search shortcode
<?php
/*
*
* template for participants list search form
*
*/
?>
<div class="wrap <?php echo $this->wrap_class ?>">
<?php echo $this->search_error_style ?>
<div class="pdb-searchform">
@xnau
xnau / pdb-set-decimal-datatype.php
Last active December 29, 2017 19:26
Describes how to set a custom datatype for a Participants Database field form element
<?php
/**
* @wordpress-plugin
* Plugin Name: Set Decimal Datatype
* Description: set a custom datatype for a Participants Database decimal form element
*/
add_filter( 'pdb-form_element_datatype', 'xnau_set_decimal_type', 10, 2 );
/**
* sets the datatype for decimal fields
*
@xnau
xnau / pdb_unapprove_unpaid_account.php
Created January 6, 2018 08:16
Demonstrates how to "unapprove" a record in Participants Database Member Payments if the account is not paid
<?php
/**
* @wordpress-plugin
* Plugin Name: Unapprove Unpaid Records
* Description: unapproves the record if the account has not been paid
*/
add_action( 'pdbmps-status_change_to_due', 'xnau_unapprove_unpaid_account' );
/**
* unapproves the record if the payment lapses
*
@xnau
xnau / pdb-month-sort.php
Last active January 15, 2018 03:27
Demonstrates how to sort by a Participants Database list of month values...or any arbitrary list of values.
<?php
/**
* Plugin Name: PDB Sort By Month
* Description: Demonstrates how to set up an arbitrary list sort in Participants Database
*/
/*
* Important: this assumes that the column you want to put the arbitrary sort on is already
* present in the sort as defined in the shortcode. For instance, in this example, the shortcode
* should have the sort set up like this: [pdb_list orderby="month" order="ASC"] then that sort
* gets replaced by the one we are setting up in this filter.
@xnau
xnau / pdb-record-member-payment-tabs-status.php
Created January 28, 2018 03:49
Demonstrates how to control the payment method according to the member's payment status
<?php
/*
* demonstrates a profile payment form where the payment is controlled by the member's payment status
*/
?>
<div class="wrap <?php echo $this->wrap_class ?>">
<?php
if ( !empty( $this->participant_id ) ) :
// output any validation errors
@xnau
xnau / pdb-login-redirect-filter.php
Last active February 6, 2018 18:30
Demonstrates how to alter the redirect according to a value in the user's record when using the PDB Login add-on
<?php
/*
Plugin Name: Redirect PDB Login
Description: Alters the redirect according to a value in the user's record when using the PDB Login add-on
*/
add_action( 'pdb-login_after_validate_submission', 'xnau_setup_pdb_login_redirect', 10, 2 );
/**
* sets up the redirect filter
*
* this checks the newly-logged-in user's record and
@xnau
xnau / pdb-list-field-control.php
Last active February 10, 2018 18:45
demonstrates how to control the display of some fields in a Participants Database record list based on the value of another field
<?php
/*
*
* template for participants list shortcode output
*
* demonstrates how to control the display of some fields based on the value of another field
*
*/
// these are the fields that we are controlling the display of
@xnau
xnau / pdb-signup-redirect-filter.php
Created February 26, 2018 20:06
Demonstrates how to enact a conditional redirect based on the submitted data from a Participants Database signup form
<?php
// place the filter on the posted data before it is submitted
add_filter( 'pdb-before_submit_signup', 'xnau_conditional_signup_redirect' );
/**
* changes the signup form "thanks" page depending on a value in the form
*
* @param array $post the posted data
* @return array post data
*/
function xnau_conditional_signup_redirect( $post )