Skip to content

Instantly share code, notes, and snippets.

@rickalday
rickalday / givewp_form_preloader.php
Created January 14, 2026 18:15
Add a simple preloader to visual builder forms created with GiveWP
<?php
add_action( 'wp_footer', function(){
?>
<script>
document.addEventListener('DOMContentLoaded', () => {
const wrapper = document.querySelector('.root-data-givewp-embed');
const iframe = wrapper?.querySelector('iframe');
if (!wrapper || !iframe) {
return;
@rickalday
rickalday / donation_id_tag.php
Created January 8, 2026 21:52
Creates a {donation_id} for GiveWP Emails
<?php
function donation_id_tag( $email_tags ) {
$new_email_tag = array(
'tag' => 'donation_id',
'description' => esc_html__( 'This tag outputs the donation ID', 'give' ),
'function' => 'get_donation_id',
'context' => 'general', // Context can be general, donor, form or donation
);
@rickalday
rickalday / give_zapier_trigger_cleanup.php
Created January 8, 2026 16:55
Add a custom 'monthly' interval to WordPress cron schedules to delete wp_give_zapier_trigger from autoload
/**
* Add a custom 'monthly' interval to WordPress cron schedules.
*/
add_filter( 'cron_schedules', 'add_custom_monthly_cron_schedule' );
function add_custom_monthly_cron_schedule( $schedules ) {
$schedules['monthly'] = array(
'interval' => MONTH_IN_SECONDS, // Approximately 30 days
'display' => __( 'Once Monthly', 'text-domain' )
);
return $schedules;
@rickalday
rickalday / give_add_donation_level_pdf_tag.php
Last active December 19, 2025 19:01
Add a PDF tag that outputs the donation leve description
<?php
use Give\ValueObjects\Money;
use Give\Donations\Models\Donation;
function give_add_donation_level_pdf_tag( $template_content, $args ) {
// during testing, uncomment the next line to see a full printed array of the possible args that you can query
//var_dump("<pre>".print_r($args,true)."</pre>");
$level_label = '';
$currency = give_get_option('currency');
$form_id = give_get_payment_form_id( $args['donation_id'] );
@rickalday
rickalday / create_missing_mampaign_tables.sql
Created December 18, 2025 19:04
Create missing Campaign tables
-- Change the wp_ prefix to match the WP prefix on your site
-- Create give_campaigns table
CREATE TABLE wp_give_campaigns (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
campaign_page_id INT UNSIGNED NULL,
form_id INT NOT NULL,
campaign_type VARCHAR(12) NOT NULL DEFAULT '',
campaign_title TEXT NOT NULL,
campaign_url TEXT NOT NULL,
short_desc TEXT NOT NULL,
@rickalday
rickalday / givewp_authorizenet_payment_description.php
Created November 14, 2025 20:46
Send custom data to Authorize.net
<?php
add_filter(
'give_authorize_recurring_payment_description',
function($description, $purchase_data, $subscription){
\Give\Framework\PaymentGateways\Log\PaymentGatewayLog::success('Contents of the variables',
[
'Purchase Data' => $purchase_data,
]
);
@rickalday
rickalday / allow_editors_only_give_campaign_pages.php
Created November 7, 2025 23:01
Restrict Editor role to Give Campaing Pages only
<?php
/**
* Allow editors to edit/delete ONLY pages that have the give_campaign_id meta key.
*/
/**
* Map meta caps so editors may only edit/delete posts that have give_campaign_id.
*
* @param array $caps Mapped capabilities to return.
* @param string $cap Capability being checked.
@rickalday
rickalday / update-givewp-form-colors.php
Created October 29, 2025 23:18
Change GiveWP's primary and secondary form colors
<?php
// Remove the inline styles from the doantion receipt page
add_action('wp_print_scripts', function () {
wp_add_inline_script('givewp-donation-confirmation-receipt', 'document.addEventListener("DOMContentLoaded", function () {
// Run after a short delay to ensure UI is ready
setTimeout(() => {
const element = document.getElementById("root-givewp-donation-confirmation-receipt");
element.removeAttribute("style");
@rickalday
rickalday / givewp_year_dropdown.php
Created October 27, 2025 20:43
Create a year dropdown field in a GiveWP form
<?php
function getYears(): array
{
$startYear = 1970;
$currentYear = date('Y');
return range($startYear, $currentYear);
}
add_action('givewp_donation_form_schema', static function (Give\Framework\FieldsAPI\DonationForm $form) {
$field = Give\Framework\FieldsAPI\Select::make('grduation_year')
->options(...getYears())
@rickalday
rickalday / givewp_non_selectable.php
Created October 13, 2025 19:12
Make the first element of a GiveWP dropdown element non-selectable
<?php
add_action("givewp_donation_form_enqueue_scripts", function () {
?>
<script>
document.addEventListener("DOMContentLoaded", function () {
// Run after a short delay to ensure UI is ready
setTimeout(() => {