Skip to content

Instantly share code, notes, and snippets.

@rickalday
rickalday / givewp-populate-from-url.php
Last active April 1, 2024 15:08
Auto populate form from URL
function give_populate_amount_name_email() {
?>
<script>
jQuery( document ).ready(function() {
( function( window, document, jQuery, undefined ) {
'use strict';
var giveCustom = {};
giveCustom.init = function() {
@rickalday
rickalday / give_export_transaction_id.php
Created March 1, 2024 17:14
Add a checkbox to export the donation Transaction ID in GiveWP donation history export
<?php
function give_export_transaction_id() {
?>
<tr class="give-export-option-fields give-export-option-custom-field">
<td scope="row" class="row-title">
<label><?php esc_html_e( 'Transaction ID:', 'give' ); ?></label>
</td>
<td class="give-field-wrap">
<div class="give-clearfix">
@rickalday
rickalday / export_option_givewp_mc_fields.php
Last active October 17, 2023 16:19
Export Mailchimp status in GiveWP
<?php
function export_option_givewp_mc_fields() {
?>
<tr class="give-export-option-fields give-export-option-custom-field">
<td scope="row" class="row-title">
<label><?php esc_html_e( 'MailChimp:', 'give' ); ?></label>
</td>
<td class="give-field-wrap">
<div class="give-clearfix">
@rickalday
rickalday / custom_salesforce_data.php
Last active September 11, 2023 15:42
Send a bunch of donation metadata to Salesforce
<?php
function addGiveSalesforceDonationArgs(
$args,
\GiveSalesforce\Salesforce\DataTransferObjects\SalesforceOpportunityData $data
) {
// Acknowledgement Status
$args['npsp__Acknowledgment_Status__c'] = "Acknowledged";
@rickalday
rickalday / give_add_phone_email_tag.php
Last active August 25, 2023 17:58
GiveWP Add Phone Email Tag
<?php
function donation_phone_email_tag( $email_tags ) {
$new_email_tag = array(
'tag' => 'give_phone',
'description' => esc_html__( 'This tag outputs the donation phone', 'give' ),
'function' => 'get_donation_phone',
'context' => 'general', // Context can be general, donor, form or donation
);
@rickalday
rickalday / export_custom_field_no_value.php
Created July 6, 2023 19:07
Export custom fields without a value
function export_option_givewp_field_api_fields() {
?>
<tr class="give-export-option-fields give-export-option-custom-field">
<td scope="row" class="row-title">
<label><?php esc_html_e( 'Custom Field Title:', 'give' ); ?></label>
</td>
<td class="give-field-wrap">
<div class="give-clearfix">
<ul class="give-export-option-custom-fields-ul">
<!-- Custom field checkbox -->
@rickalday
rickalday / stripe-pass-custom-meta-for-payments.php
Created June 29, 2023 23:35
Pass custom field data to Stripe when payment is processed.
<?php
function give_stripe_custom_payment_meta( $charge_args ) {
// Sanitize the input posted data to the form.
$posted_data = give_clean( filter_input_array( INPUT_POST ) );
//Uncomment the followign line to print the $posted_data array to the error log
//error_log(print_r($posted_data, TRUE));
//Get form ID
@rickalday
rickalday / give_include_fund_payment_meta.php
Created June 23, 2023 20:42
Include fund in Stripe payment metadata
<?php
use GiveFunds\Models\Fund;
use GiveFunds\Repositories\Funds;
use GiveFunds\Repositories\Revenue;
function give_include_fund_payment_meta( $charge_args ) {
if ( ! defined( 'GIVE_FUNDS_ADDON_VERSION' )) {
return;
@rickalday
rickalday / add_donor_created_date.php
Last active June 7, 2023 18:24
Add Donor Creation Date to Donor Export File
<?php
function give_add_custom_column_to_export_donor( $default_columns ) {
$default_columns['date_created'] = esc_html__( 'Donor Created Date', 'give' );
return $default_columns;
}
add_filter( 'give_export_csv_cols_donors', 'give_add_custom_column_to_export_donor' );
add_filter( 'give_export_donors_get_default_columns', 'give_add_custom_column_to_export_donor' );
@rickalday
rickalday / add_give_transaction_id_tag.php
Created March 27, 2023 18:47
GiveWP Transaction ID Email Tag
<?php
function add_give_transaction_id_tag() {
give_add_email_tag(
array(
'tag' => 'transaction_id', // The tag name.
'desc' => __( 'Outputs the payment gateway transaction ID', 'give' ),
'func' => 'custom_transaction_id_tag', // Callback to function below.
'context' => 'donation', // This tag can be for both admin and donor notifications.
'is_admin' => false, // default is false. This is here to simply display it as an option.
)