Skip to content

Instantly share code, notes, and snippets.

@rickalday
rickalday / company_or_name.php
Last active July 22, 2025 18:36
Add {company_or_name} tag for PDF Receipts.
<?php
/**
* Add {company_or_name} tag to GiveWP PDF Receipts using the give_pdf_compiled_template_content filter.
* Outputs the Company name if provided, otherwise outputs donor's full name.
*/
add_filter( 'give_pdf_compiled_template_content', function( $template_content, $args ) {
//var_dump("<pre>".print_r($args,true)."</pre>");
//
// Make sure payment ID is available.
$payment_id = ! empty( $args['donation_id'] ) ? absint( $args['donation_id'] ) : 0;
@rickalday
rickalday / givewp_authorize_payment_description.php
Created July 22, 2025 17:34
Filter the payment description sent to Authorize.net
<?php
add_filter(
'give_authorize_recurring_payment_description',
function($description, $purchase_data, $subscription){
/** Uncomment this block to get the $purchase_data array listed in Donations -> Tools -> Logs
* \Give\Framework\PaymentGateways\Log\PaymentGatewayLog::success('Contents of the variables',
* [
* 'Purchase Data' => $purchase_data,
@rickalday
rickalday / set_donation_frequency_from_url.php
Created July 18, 2025 16:48
Sets the donation frequency based on the url parameter. Eg. yoursite.com/?payment_type=monthly
<?php
add_action("givewp_donation_form_enqueue_scripts", function () {
?>
<script>
document.addEventListener("DOMContentLoaded", function () {
const validValues = ["one-time", "daily", "week", "month", "quarter", "year"];
const params = new URLSearchParams(window.parent.location.search);
const paymentType = params.get("payment_type");
if (!paymentType || !validValues.includes(paymentType)) return;
@rickalday
rickalday / givewp_pdf_cutom_tags.php
Created July 16, 2025 23:58
Sample function to include form custom field data in GiveWP PDF Receipts
<?php
function givewp_pdf_cutom_tags( $template_content, $args ) {
//$donor_info = give_get_payment_meta_user_info( $args['donation_id'] );
$post = get_post($args['donation_id']);
if ($post->post_parent) {
$post_id = $post->post_parent;
} else {
$post_id = $args['donation_id'];
}
@rickalday
rickalday / custom_tributes_email_tags.php
Created July 1, 2025 21:22
Custom Tributes Email Tags for the GiveWP Tributes add-on
<?php
add_action( 'give_email_tags', 'register_email_custom_tributes_tags' );
function register_email_custom_tributes_tags($email_tags)
{
$email_tags = array_merge(
$email_tags,
[
[
'tag' => 'honoree_fullname', // The tag name.
@rickalday
rickalday / donor_export_company.php
Created July 1, 2025 01:10
Include Company name in GiveWP Donor Export
<?php
add_filter( 'give_export_donors_get_default_columns', static function($columnData) {
$columnData['donor_company'] = esc_html__( 'Company', 'give' );
return $columnData;
});
use Give\Donors\Models\Donor;
add_filter( 'give_export_get_data_donors', static function($exportData) {
foreach($exportData as $key => $data){
@rickalday
rickalday / give_stripe_custom_payment_meta.php
Last active July 22, 2025 22:25
Include fund in Stripe payment metadata - Visual Builder Forms
<?php
use GiveFunds\Models\Fund;
use GiveFunds\Repositories\Funds;
use GiveFunds\Repositories\Revenue;
function give_stripe_custom_payment_meta( $args ) {
// Sanitize the input posted data to the form.
$posted_data = give_clean( filter_input_array( INPUT_POST ) );
@rickalday
rickalday / populate-tributes-from-url.php
Last active May 30, 2025 23:39
Populate Tributes from URL parameters
/**
* EXAMPLE: https://example.com/donations/give-form/?tribute=yes&first=Peter&last=Joseph
**/
add_action( 'givewp_donation_form_enqueue_scripts', function(){
?>
<script>
document.addEventListener("DOMContentLoaded", function () {
// Helper function to get URL parameters
function getUrlParam(param) {
@rickalday
rickalday / wp_give_campaigns.sql
Created April 30, 2025 18:01
SQL command to create GivWP 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,
long_desc TEXT NOT NULL,
campaign_logo TEXT NOT NULL,
Error from migrate_forms_to_campaign_forms:
Migration Failed
Migration ID: migrate_forms_to_campaign_forms
Last run: 2025-04-04 15:10:48
Error details:
Give\Framework\Migrations\Exceptions\DatabaseMigrationException Object
(
[message:protected] => An error occurred while creating initial campaigns
[string:Exception:private] =>