Skip to content

Instantly share code, notes, and snippets.

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] =>
<?php
/**
* This template is used to display the donation grid with [donation_grid]
*/
use Give\Helpers\Form\Template;
use Give\Helpers\Form\Utils as FormUtils;
// Exit if accessed directly.
if (!defined('ABSPATH')) {
@rickalday
rickalday / givewp_export_full_address.php
Created April 3, 2025 19:37
Include full state and country names in GiveWP's Export Donation History
<?php
function givewp_export_full_address( $data, $payment, $columns, $instance ) {
$address = $payment->address;
$data['address_line1'] = isset( $address['line1'] ) ? $address['line1'] : '';
$data['address_line2'] = isset( $address['line2'] ) ? $address['line2'] : '';
$data['address_city'] = isset( $address['city'] ) ? $address['city'] : '';
@rickalday
rickalday / give_export_base_amount.php
Last active April 3, 2025 17:49
Include Base Amount data in Donation History Export Tool
<?php
function give_export_base_amount() {
?>
<li>
<label for="give-export-payment-base_amount">
<input type="checkbox" checked name="give_give_donations_export_option[base_amount]" id="give-export-base_amount"><?php _e( 'Base Amount', 'give' ); ?>
</label>
</li>
<?php
@rickalday
rickalday / populate_v3_dropdown_from_url.php
Created March 31, 2025 19:51
Populate GiveWP v3 form dropdown from URL value
<?php
add_action('givewp_donation_form_schema', function($form) {
//Get field by name attribute
$field = $form->getNodeByName('field_name_here');
// if the field is not found, return
if (!$field) {
return;
}
// get the current default value
@rickalday
rickalday / remove_duplicate_keys.sql
Created March 28, 2025 18:02
SQL Query to remove duplicate metakeys from a WordPress table
--This applies to the give_formmeta table specifically but it can be used for any other table by editing the table name
DELETE FROM wp_give_formmeta WHERE meta_id NOT IN (
SELECT *
FROM (
SELECT MAX(meta_id)
FROM wp_give_formmeta
GROUP BY form_id, meta_key
) AS x
) ORDER BY meta_key
@rickalday
rickalday / givewp_pdf_nifnie_tag.php
Created March 28, 2025 00:13
Incluir DNI en recibo PDF
<?php
function givewp_pdf_nifnie_tag( $template_content, $args ) {
$meta_keys = ['nifnie', 'dninie', 'dniniecif'];
$buyer_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 / give_export_gift_aid.php
Last active March 18, 2025 17:26
Export Gift Aid data in Donation History Export Tool
<?php
function give_export_gift_aid() {
?>
<li>
<label for="give-export-payment-gift_aid">
<input type="checkbox" checked name="give_give_donations_export_option[gift_aid]" id="give-export-gift_aid"><?php _e( 'Gift Aid', 'give' ); ?>
</label>
</li>
<?php
@rickalday
rickalday / set_specific_country_state.php
Created March 14, 2025 16:59
Limit Billing Address Block to specific country and state
add_filter('give_countries', 'my_custom_give_countries');
function my_custom_give_countries() {
$countries = array(
'CA' => esc_html__( 'Canada', 'give' ),
);
return $countries;
}
<?php
@rickalday
rickalday / make_comment_required.php
Created March 11, 2025 20:18
Make the Commens block field required in GiveWP forms
<?php
add_action('givewp_donation_form_schema', function($form) {
$comment = $form->getNodeByName('comment');
// if the comment field is not found, return
if (!$comment) {
return;
}
// require field
$comment->required(true);