Dokumentation für Wohltätigkeitsorganisationen

Erfahren Sie, wie Sie mit klaren Schritt-für-Schritt-Anleitungen das Beste aus Charitable herausholen.

Donation Fields API

The Donation Fields API is provides a powerful, flexible way to add, remove and edit your donation fields.

What are donation fields?

Donation fields are any bits of information about a donation that are available for you to use. As an example, here are some of the fields available by default:

  • first_name – Get the first name of the donor.
  • last_name – Get the last name of the donor.
  • amount_formatted – Get the donation amount, formatted according to your site’s currency settings (e.g. $50.00).
  • date – The date that the donation was made.
  • gateway_label – The payment method the donor used.

How do I get the value for a particular donation field?

You can get the value of any donation field through the donation’s Charitable_Donation object.

The first step is to get a Charitable_Donation object:

$donation_id = 123; // Replace with your Donation's ID.
$donation    = charitable_get_donation( $donation_id );

Next, you can get the field’s value by calling get() on the object, as you can see in the examples below:

$first_name = $donation->get( 'first_name' );
$date       = $donation->get( 'date' );
$gateway    = $donation->get( 'gateway_label' );

To put it all together:

$donation_id = 123;
$donation    = charitable_get_donation( $donation_id );
$first_name  = $donation->get( 'first_name' );

How do I add a new field to my donation form?

Adding a new field is a two-step process.

First, you will create a new Charitable_Donation_Field object which will define your field’s parameters: its label, the type of value it stored, how it should be included in the donation form (if at all), whether it should be added to the Donations export file, and more.

Next, you add this field to the Charitable_Donation_Field_Registry class, which provides a way to store and retrieve donation fields.

Let’s see how this works in an example:

/**
 * Create a callback function on the `init` hook, where we
 * can register our donation field.
 */
add_action( 'init', function() {

    /* Create the `Charitable_Donation_Field` object. */
    $field = new Charitable_Donation_Field(
        'my_custom_field',
        array(
            'label'          => __( 'My Custom Field' ),
            'data_type'      => 'meta', 
            'donation_form'  => array(
                'type'       => 'text',
                'required'   => false,
                'show_after' => 'phone',
            ), 
            'admin_form'     => true,
            'show_in_meta'   => true,
            'show_in_export' => true,
            'email_tag'      => array(
                'description' => __( 'The custom field value' ),
            ),
        )
    );

    /* Get the `Charitable_Donation_Field_Registry` instance. */
    $fields = charitable()->donation_fields();

    /* Add the new field. */
    $fields->register_field( $field );
} );

In the example above, we have created a new field with a key of my_custom_field. Here’s what its defined parameters mean:

  • Its label is “My Custom Field”. This is what will be used in the donation form, in the admin donation details area and in the donations export as the column header.
  • Its data type is meta. This means that it will be stored as a meta field specific to that donation.
  • It is set up to be shown in the donation form, right after the phone field. It’s an optional field.
  • It will also be added to the admin donation form.
  • When viewing the details for the donation, you will be able to see what the donor entered for this field in the “Donation Details” section.
  • When you download a donations export, a new “My Custom Field” column will be added, showing what donors entered for this field.
  • A new email tag has been created for this field, so you can easily include it in donation-specific emails, like the Donation Receipt (for donors), or the Donation Notification (for administrators).

This is a relatively simple example, but it achieves a lot. Click here for a more detailed breakdown of all the available parameters when creating Charitable_Donation_Field objects.

How do I change an existing donation field?

To change an existing donation field, you first retrieve the field from the Charitable_Donation_Field_Registry, and then update the field value.

To update the field value, we can call set() on the field, or use the magic setter.

/**
 * Create a callback function on the `init` hook, where we
 * can start changing the donation field.
 */
add_action( 'init', function() {

    /* Get the Donation Field Registry object. */
    $fields = charitable()->donation_fields();

    /* Get the field we want to change. */
    $field  = $fields->get_field( 'phone' );
    
    /**
     * Change #1: Make it a required field (uses set()).
     * Change #2: Change the label (uses magic setter).
     */
    $field->set( 'donation_form', 'required', true );
    $field->label = 'Phone Number';
} );

For more information about how to update field arguments, see the detailed reference for those class methods:

How do I add a field to a specific campaign’s donation form?

If you want a new or existing field to only show for certain campaigns, you can do this by adding a new function which controls whether the field shows in the donation form.

If you are adding a new field, you will first to create the donation field, so follow those steps first.

Now you can hide the field you registered from all donation forms other than the one you want it to show on:

add_filter( 'charitable_donation_form_user_fields', function( $fields, $form ) {

    /* If the field doesn't exist, stop right here. */
    if ( ! array_key_exists( 'my_custom_field', $fields ) ) {
        return $fields;
    }

    /* Match any campaign that DOESN'T have a slug of 'special-campaign' */
    if ( 'special-campaign' !== $form->get_campaign()->post_name ) {    
        unset( $fields['my_custom_field'] );
    }
    
    return $fields;
}, 10, 2 );

What’s happening here?

  • We only want the my_custom_field field to show on the campaign with a slug of ‘special-campaign’.
  • The field will show in all campaigns by default, so our code checks if the campaign doesn’t have a slug of ‘special-campaign’ and then removes it.

You can change the condition under which the field is shown. For example, you can change the field to only show for campaigns in a certain category, or for campaigns that have a specific parent campaign (i.e. fundraisers for one of your peer-to-peer fundraising campaigns).

How do I change a donation field for a particular campaign?

The approach used above to show a field on a particular campaign can be adapted to change a donation field for a particular campaign.

For example, if you only want to accept donations from donors in a specific country for a certain campaign, you can achieve that with the following code:

add_filter( 'charitable_donation_form_user_fields', function( $fields, $form ) {
    /* If a country field doesn't exist, stop right here. */
    if ( ! array_key_exists( 'country', $fields ) ) {
        return $fields;
    }

    if ( 'south-africa-only' === $form->get_campaign()->post_name ) {
        $fields['country']['options'] = array(
            'ZA' => 'South Africa',
        );
    }	

    return $fields;

}, 10, 2 );

This code will make it so that the campaign with a slug of ‘south-africa-only’ will only display South Africa as a valid country option.

How do I make a donation field show based on user input?

The previous two examples showed how to add / change donation fields based on the donation form’s campaign. But what if you want to show or hide a field based on user input?

Handling this requires a different approach, using Javascript. If you are a confident developer, you can add this through a new Javascript file, but in the example below we will use the wp_add_inline_script function to add our custom Javascript without needing to create, register and enqueue a new script.

In the example below, we are only showing our custom field, my_custom_field, when the donor is from the United States:

add_action( 'wp_enqueue_scripts', function() {
    wp_add_inline_script( 'charitable-script', "
        jQuery('body').on('charitable:form:loaded', (event, donationForm) => {
            var countryField = donationForm.get_input('country');
            function toggleCustomField() {
                donationForm.get_input('my_custom_field').parent().toggle('US' === countryField.val());
            }
            countryField.on('change', toggleCustomField).trigger('change');
        });
    " );
} );

Full list of default donation fields

The following fields are added by Charitable and its extensions:

SchlüsselBeschreibung
donation_idThe donation ID
first_nameThe donor’s first name.
last_nameThe donor’s last name.
donorThe donor’s full name.
emailThe donor’s email address.
donor_addressThe donor’s full address, formatted.
addressThe donor’s first address field.
address_2The donor’s second address field.
cityThe donor’s city.
stateThe donor’s state.
postcodeThe donor’s postcode.
countryThe donor’s country.
phoneThe donor’s phone number.
campaignsThe campaign that received the donation.
campaign_categories_listThe categories that the campaign is in.
amount_formattedThe donation amount, formatted according to your currency settings.
DatumThe date of the donation.
timeThe time the donation was made.
statusThe donation status. This returns the raw value of post_status.
status_labelThe donation status as a more readable label.
donation_gatewayThe payment gateway used for the donation.
gateway_labelThe payment gateway as a reader-friendly string.
donation_keyThe unique donation key.
gateway_transaction_idThe transaction ID for the donation in the payment gateway that was used (i.e. PayPal, Stripe).
test_modeWhether the donation was made in test mode.
donation_summaryA readable summary of the donation, listing the campaign receiving the donation & the amount donated.
contact_consentWhether the donor gave their consent to be contacted.
cover_feesWhether the donor covered fees.
Added by Fee Relief.
fee_amountThe amount of processing fees paid by the donor.
Added by Fee Relief.
fee_amount_formattedThe amount of processing fees paid by the donor, formatted according to your currency settings.
Added by Fee Relief.
total_donation_with_feesThe total donation amount including processing fees.
Added by Fee Relief.
total_donation_with_fees_formattedThe total donation amount including processing fees, formatted according to your currency settings.
Added by Fee Relief.
consent_to_trackWhether the donor has given permission to have their newsletter activity tracked (opens, clicks). This only applies if you are using Campaign Monitor.
Added by Newsletter Connect.
anonymous_donationWhether the donor chose to remain anonymous.
Added by Anonymous Donations.
donor_commentThe comment left by the donor.
Added by Donor Comments.
giftaidWhether the donor claimed Gift Aid.
Added by Gift Aid.
giftaid_declarationThe declaration the donor agreed to when they claimed Gift Aid.
Added by Gift Aid.
titleThe donor’s title (Mr, Mrs, Ms, etc.).
Added by Gift Aid.
address_3The third line in the donor’s address.
Added by Gift Aid.

Haben Sie noch Fragen? Wir helfen Ihnen gerne weiter!

Zuletzt geändert:

Was ist neu bei Charitable

Die neuesten Updates anzeigen
🔔 Abonnieren Sie, um unsere neuesten Updates zu erhalten
📧 E-Mails abonnieren

E-Mail-Abonnement

Abonnieren Sie unseren Newsletter

Wir werden Sie nicht spammen. Wir senden nur eine E-Mail, wenn wir glauben, dass sie Ihnen wirklich hilft. Abmeldung jederzeit möglich!

GiveWP Migrationen Neu

White Glove Migrationsservice für GiveWP

Erwägen Sie den Wechsel Ihrer Spendenplattform von GiveWP zu Charitable, möchten aber nicht riskieren, Ihre Daten zu verlieren oder eine komplexe technische Einrichtung selbst vorzunehmen? Der White Glove Migrationsservice von Charitable bietet:

👥 Makellose Spenderzuordnung: Übertragen Sie Ihre gesamte Unterstützerdatenbank sicher und ohne Datenverlust.

📊 Vollständige Finanzhistorie: Bewahren Sie sorgfältig jede historische Transaktion für eine kontinuierliche, genaue Berichterstattung auf.

🔄 Nahtlose wiederkehrende Spenden: Übertragen Sie aktive Dauerabonnements sicher, ohne Ihre Einnahmen zu unterbrechen oder Ihre Spender zu zwingen, ihre Informationen zu aktualisieren.

💳 Keine Gateway-Unterbrechungen: Nutzen Sie weiterhin Stripe, PayPal oder jeden anderen mit GiveWP kompatiblen Prozessor, den Sie bereits lieben.

🚀 Experten-Technik-Setup: Lehnen Sie sich zurück, während unser Team die schwere Arbeit übernimmt, Ihre Formulare zu installieren und zu konfigurieren – außerdem erhalten qualifizierte Benutzer ein ganzes Jahr lang kostenloses Charitable Pro.

Besuchen Sie diese Seite, um mehr zu erfahren.

Automatisierung Verbesserung

📢 Neue Funktion: Automation Connect 2.0 ist da! 🚀

Sie möchten Ihre Spenden-Daten mit Tools wie Mailchimp, Slack oder Google Sheets verbinden, aber keinen Entwickler einstellen oder benutzerdefinierten Code schreiben? Charitalbes neues Automatisierungs-Addon bietet:

⚡ 17 Event-Trigger: Lösen Sie sofort Webhooks für die erste Spende eines Spenders, wiederkehrende Zahlungen oder erreichte Kampagnenmeilensteine aus.

🎯 Intelligente bedingte Logik: Verwenden Sie leistungsstarke UND/ODER-Logik über 11 Felder hinweg, um Daten nur dann zu senden, wenn sie Ihren genauen Kriterien entsprechen, z. B. Newsletter-Opt-ins.

📊 Benutzerdefinierte Payload-Steuerung: Wählen Sie aus über 80 sauberen Datenfeldern für Spender-, Spenden- und Kampagnenmetadaten, damit Ihre Apps genau das erhalten, was sie benötigen.

🚀 Vorkonfigurierte Plattform-Vorlagen: Überspringen Sie die Einrichtung von Grund auf mit fertigen Vorlagen für Zapier, Make.com, n8n, HubSpot und Slack.

🛡️ Zuverlässige Entwickler-Tools: Steuern Sie Ihre Workflows mit signierten HMAC-SHA256-Payloads, vollständigen WordPress-Filtern und automatischen Wiederholungsprotokollen.

Automatisierung Verbesserung

🔌 Charitable trifft Zapier: Verbinden Sie sich mit über 7.000 Apps und automatisieren Sie Ihre Spendenaktionen

Müde vom manuellen Kopieren von Spendeninformationen in Buchhaltungsbögen oder vom Nachverfolgen neuer Spenderanmeldungen? Bringen Sie Ihre Verwaltungsaufgaben auf Autopilot. Charitable ist jetzt offiziell auf Zapier verfügbar und bietet Ihnen eine leistungsstarke No-Code-Möglichkeit, Ihre Spendenaktionen direkt mit dem Rest Ihrer bevorzugten Tools zu verbinden.

Jede Spende, jede Spenderanmeldung und jeder Kampagnenmeilenstein kann jetzt nahtlos einen automatisierten Workflow auslösen.

Was ist neu:

♾️ Verbinden Sie sich mit über 7.000 Apps: Verknüpfen Sie Ihre Charitable-Kampagnen mit alltäglichen Softwareanwendungen wie Google Sheets, QuickBooks, Slack, Mailchimp, HubSpot, Notion, Airtable und Tausenden mehr.

⚡ 12 leistungsstarke Trigger: Erstellen Sie tiefgreifende Workflows mit intelligenten Automatisierungs-Triggern, die den gesamten Spendenlebenszyklus abdecken – einschließlich Neue Spende, Neuer Spender, Abonnement gekündigt und Kampagnenziel erreicht.

📋 Vorkonfigurierte Aktionsvorlagen: Beginnen Sie in drei Minuten oder weniger mit unseren vorgefertigten Vorlagenkombinationen, wie z. B. dem automatischen Protokollieren neuer Spenden direkt in ein Google Sheet oder dem Auslösen benutzerdefinierter Spender-Willkommens-E-Mails über Gmail.

🚫 Kein Code erforderlich: Keine komplexen Webhooks oder benutzerdefinierten PHP-Skripte erforderlich. Wählen Sie einfach Ihren Trigger, wählen Sie Ihre App, ordnen Sie Ihre Felder zu und lassen Sie Zapier die Hauptarbeit erledigen.

Bereit, Stunden an Verwaltungszeit zu sparen? Holen Sie sich Charitable Pro mit dem Automation Connect Addon noch heute und starten Sie Ihren ersten Zap!

Verbesserung Zahlungen

🚀 Einführung von PayPal Commerce: Eine Verbindung, sechs Spendenmöglichkeiten

Spender erwarten moderne, flexible Zahlungsoptionen, wenn sie eine Sache unterstützen. Wenn sie ihre bevorzugte Methode nicht auf ihrem Spendenformular sehen, verschwinden sie oft ohne ein Wort. Mit PayPal Commerce bringen wir ein komplett modernisiertes Checkout-Erlebnis direkt in Ihre Kampagnen.

Genießen Sie eine einzige Integration, die Ihre Formulare verbessert, das Spenden nahtlos gestaltet und Ihnen hilft, jede einzelne Spende zu erfassen.

Was ist neu:

🔌 Ein-Klick-Verbindung: Überspringen Sie unübersichtliche API-Schlüssel und Entwicklerdokumentationen. Klicken Sie einfach auf „Mit PayPal verbinden“, melden Sie sich bei Ihrem Geschäftskonto an und Ihr modernes Formular ist in weniger als fünf Minuten live.

💳 Sechs Spendenmöglichkeiten: Bieten Sie Ihren Unterstützern sofortigen Zugriff auf PayPal-Guthaben, Venmo (US), „Später bezahlen“-Finanzierung, wichtige Kredit-/Debitkarten, Apple Pay (Safari) und Google Pay (Chrome) – alles über dasselbe Formular.

🔄 Flexible wiederkehrende Spenden: Unterstützt vollständig monatliche Spenden. Wählen Sie zwischen der PayPal-Abonnement-API (automatisch von PayPal verwaltet) oder Vault + Cron (sicher direkt auf Ihrer Website verwaltet).

💬 Freundliche Fehlerbehebung: Keine verwirrenden Browser-Warnungen mehr. Wenn eine Zahlung abgelehnt wird, sehen Spender klare, Inline-Nachrichten, die sie anleiten, wie sie das Problem beheben und ihre Spende abschließen können.

Bereit für PayPal, modernisiert? Aktualisieren Sie auf Charitable Pro 1.8.15+ (oder Charitable Lite 1.8.11+) und verbinden Sie Ihr Konto noch heute!

Kampagnen Neu

⏳ Kampagnen-Countdown: Steigern Sie die Dringlichkeit und erhöhen Sie die Spenden

Dringlichkeit ist eines der mächtigsten Werkzeuge im Fundraising! Lernen Sie den Kampagnen-Countdown kennen – einen Live-Echtzeit-Timer, der Prokrastination in sofortige Großzügigkeit umwandelt.

campaign_countdown_animation

Was ist neu:

⏱️ Live-Echtzeit-Dringlichkeit: Verfolgen Sie Tage, Stunden, Minuten und Sekunden bis zur Frist Ihrer Kampagne mit live aktualisierten visuellen Countdowns.

🎨 Auf Ihren Look zugeschnitten: Wählen Sie zwischen umrandeten Kacheln im Box-Stil oder einer sauberen, einzeiligen Inline-Anzeige. Passen Sie Ihr Design sofort mit Schriftart- und tiefen Farbkontrollen an.

🛠️ Platzieren Sie es überall: Fügen Sie den Countdown überall ein, wo Sie möchten, mit dem Kampagnen-Builder-Feld, einem dedizierten Gutenberg-Block oder einem einfachen Shortcode.

🚨 Intelligente Ablaufaktionen: Volle Kontrolle über den Endzustand – wählen Sie, ob der Timer automatisch durch eine benutzerdefinierte Nachricht ersetzt, auf Null eingefroren und mehr werden soll.