Gemeinnütziger Blog

Alles, was Sie über Charitable und unser Team wissen müssen.

Tutorial: Benutzerdefinierte Belegseiten pro Kampagne festlegen

Zuletzt aktualisiert am

  • Von

By default, your site will have a single donation receipt page, which donors will automatically be redirected to after they make their donation.

You can use the auto-generated receipt page provided by Charitable out of the box, or you can specify a particular page to be used as your donation receipt page. Check the guide below if you’re not sure how to do this:

But what if you want to use a different receipt page for different campaigns? That isn’t possible out of the box, but thanks to Charitable’s built-in flexibility, it’s possible to achieve this with just two PHP functions.

The Solution

Our solution will add a new field to the campaign editor which allows you to select a static page as the donation receipt page for your campaign. Unless you choose a specific page, it will use the default option, which is whatever is set at Charitable > Settings > General for the “Donation Receipt Page” option.

I will explain the solution below, but if you just want the code, you can download it from Github:

https://github.com/Charitable/Charitable-Custom-Campaign-Receipt-Pages

Step 1: Add our function

As with the last two tutorials, this one starts with a PHP function which will run when the init hook is called within WordPress. init is a hook that happens early on while WordPress is loading, before the page has started rendering.

add_action( 'init', function() {
    // Our code will go in here.
} );

We are using an anonymous function here, which is fine as long as you are on a version of PHP greater than 5.2.

If you’re not sure how to add this to your site, check out our guide:

Step 2: Add the field to the Campaign editor

We can now add our “Donation Receipt Page” setting by registering a new field using the Campaign Fields API.

add_action( 'init', function() {

	/**
	 * Create a new field as an instance of `Charitable_Campaign_Field`.
	 *
	 * See all available arguments at:
	 *
	 * @https://github.com/Charitable/Charitable/blob/ef9a468fbdd6fa83307abe6ac0c38896f625cf45/includes/fields/class-charitable-campaign-field.php
	*/
	$campaign_field = new Charitable_Campaign_Field( 'donation_receipt_page', array(
		'label'      => 'Donation Receipt Page',
		'data_type'  => 'meta',
		'admin_form' => array(
			'type'     => 'select',
			'required' => false,
			'options'  => array(
				'default' => 'Use the default donation receipt page',
				'pages'   => array(
					'options' => charitable_get_pages_options(),
					'label'   => 'Pages',
				),
			),
			'default'  => 'default',
			'section'  => 'campaign-donation-options',
		),
                'show_in_export' => true,
	) );

	/**
	 * Now, we register our new field.
	 */
	charitable()->campaign_fields()->register_field( $campaign_field );

} );

This is the same approach that we used in the previous two tutorials, so if you read those this will look quite familiar to you. One new bit is how the field’s admin_form setting is set up:

'admin_form' => array(
	'type'     => 'select',
	'required' => false,
	'options'  => array(
		'default' => 'Use the default donation receipt page',
		'pages'   => array(
			'options' => charitable_get_pages_options(),
			'label'   => 'Pages',
		),
	),
	'default'  => 'default',
	'section'  => 'campaign-donation-options',
),

The type is set to select, which means that a dropdown select field will be used. Select fields require a set of options, which are passed as an array. Our array includes first of all a default choice, followed by a list of pages, retrieved using the charitable_get_pages_options() function. If you’re familiar with HTML, the way this is structured means that the options array inside pages creates an optgroup element, with label set as the label.

Our new Donation Receipt Page field

Step 3: Override the default donation receipt page

Within Charitable, the donation receipt URL for a particular donation is retrieved like this:

charitable_get_permalink( 'donation_receipt_page', array(
    'donation_id' => $donation_id,
) );

This function in turn uses the Endpoint API, which provides a structured way to deal with important endpoints within Charitable, such as campaigns, donation pages, the login page and the donation receipt page.

What is important for our case is that the returned permalink can be filtered. In the case of the donation receipt page, the filter to use is charitable_permalink_donation_receipt_page. It provides two parameters:

  • $default – The default permalink to be used. We will fall back to this if the campaign has not set a custom receipt page, or if it’s using the default.
  • $args – An array containing the donation ID.

Step 3a: Create the outline of the callback function

First of all, let’s see what the structure of our callback function will look like:

/**
 * Filter the page to redirect the donor to after making their donation.
 *
 * @param  string $default The endpoint's URL.
 * @param  array  $args    Mixed set of arguments.
 * @return string
 */
add_filter( 'charitable_permalink_donation_receipt_page', function( $default, $args ) {

   // Code goes here.

}, 10, 2 } );

As you can see, we are defining an anonymous function that is hooked into the charitable_permalink_donation_receipt_page filter. Importantly, our last line sets the callback function to operate with priority 10 (the default) and receive 2 parameters.

Step 3b: Get the campaign for the donation receipt

The $args parameter will include a donation_id property. We use this to get a Charitable_Donation object, and in turn use that to get the Charitable_Campaign object:

/**
 * Get the donation object.
 */
$donation_id = isset( $args['donation_id'] ) ? $args['donation_id'] : get_the_ID();
$donation    = charitable_get_donation( $donation_id );

/**
 * Get the campaign that received the donation.
 */
$campaign_id = current( $donation->get_campaign_donations() )->campaign_id;
$campaign    = charitable_get_campaign( $campaign_id );

Step 3c: Get the campaign’s donation receipt page

Now that we have a Charitable_Campaign object, we can get the donation receipt page setting for the campaign with the get() method:

/**
 * Get the campaign's donation receipt page.
 */
$receipt_page = $campaign->get( 'donation_receipt_page' );

Step 3d: Check whether to return the default receipt URL

Remember that you can set the campaign to use the default receipt. It’s also possible that you haven’t updated your campaign since adding the Donation Receipt Page setting, in which case the $receipt_page variable will be false. If either of these is the case, we will return the $default variable since we don’t have a custom receipt for this campaign:

/**
 * If we haven't set a donation receipt page or we chose
 * the default option, return the default.
 */
if ( ! $receipt_page || 'default' == $receipt_page ) {
    return $default;
}

Step 3e: Return the custom receipt URL

If we’re still around at this point, it means that a custom receipt page is set for this campaign. All that’s left to do is to get the permalink for that page and then append the donation_id to it, as well as donation_receipt. The resulting URL will look like this:

https://mysite.com/my-custom-receipt-page/?donation_id=123&donation_receipt=1

Here’s how we do that:

/**
 * Get the permalink for the receipt page and then append
 * the donation_id and donation_receipt arguments to it.
 */
$receipt_page_url = get_permalink( $receipt_page );
$receipt_page_url = add_query_arg(
	array(
		'donation_id'      => $donation_id,
		'donation_receipt' => 1,
	),
	$receipt_page_url
);

/**
 * Return the escaped URL.
 */
return esc_url_raw( $receipt_page_url );

get_permalink is a core WordPress plugin used to get the URL for a particular page or post. We use that as the basis for our URL, and then append the required query arguments to it with add_query_arg. Finally, we return it as an escaped value with esc_url_raw.

Extra Step: Set up your custom receipt page

This solution allows you to use any page as a donation receipt page. Chances are, you would like to show information about the donation to the donor when they land on the receipt. To include this, you can use the [donation_receipt] shortcode; it will show the dynamic receipt information that is normally shown on Charitable receipts.

Bonus ideas for customizing the donation receipt page

We’ve seen here how to customize the donation receipt page on a per-campaign basis. But what if you would like to use a different donation receipt page based on a different factor?

Over on our Code Snippets library, we have a couple snippets available that show you how you can use a different donation receipt in other scenarios:

Got an idea for another tutorial?

If you have an idea for another tutorial, I’d love to hear it! Leave a comment below or get in touch via our Support page.

Offenlegung: Unsere Inhalte werden von unseren Lesern unterstützt. Das bedeutet, wenn Sie auf einige unserer Links klicken, können wir eine Provision verdienen. Wir empfehlen nur Produkte, von denen wir glauben, dass sie unseren Lesern einen Mehrwert bieten.

Hinterlassen Sie eine Antwort

Ihre E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind markiert *

Erhalten Sie kostenlose Tipps und Ressourcen direkt in Ihren Posteingang, zusammen mit über 60.000 anderen

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!

Video der Woche:

Sehen Sie sich weitere Videos auf unserem YouTube-Kanal an.

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!

💂‍♂️ New DonationGuard 🛡️ Automatically Protects Your Donations!

Worried about card testing attacks or spam bots flooding your donation forms, but don’t want to ruin the giving experience for your real supporters? Charitable’s DonationGuard features:

🛡️ Real-Time Bot Detection: Actively monitors every donation submission for five distinct attack signals without slowing down your human donors.

📊 Smart Traffic Scoring: Instantly evaluates activity against a learned baseline of your site’s normal donation rhythms to catch sneaky, slow-drip card testing.

🚨 Severity-Tiered Alerts: Immediately opens structured “Attack Records” and notifies you via email and admin alerts the moment a campaign starts taking fire.

🎯 Single-Click Defense: Deploy instant security using the “Recommended Settings” preset to turn on Honeypot, Time Trap, and Rate Limit modules all at once.

🚫 Automated Blocklists: Permanently stop repeat offenders by automatically blocking suspicious email addresses based on your customized rules.

Besuchen Sie diese Seite, um mehr zu erfahren.

GiveWP Migrationen Neu

🧤 White Glove Migration Service for 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!