Charitable Blog

Everything you need to know about Charitable and our team.

How to Add a Custom Text Field To A Donation Form

Adding A Custom Text Field To A Donation Form

Last updated on

  • By

Charitable donation forms can be customized in various ways thanks to Charitable’s internal API. One of the most requested features is to add one or more custom fields to the Charitable donation form. In this post we are going to show you how you can add a new field – a textbox – to your donation forms using Charitable.

Even if you’re aren’t a developer, adding code snippets are easy to do. You have the option of installing a code snippet plugin of your choice but since Charitable works great with WPCode… we will assume you are using that for this post.

Note: If you ARE a developer then you are aware code snippets can be added to the functions.php of a WordPress theme or within it’s own plugin… if you go down this route we recommend you follow our instructions on best practices for writing code with Charitable. You should also be reading our Charitable_Donation_Field documentation.

Using WPCode

The first step is to install WPCode itself. You can install and activate the free version just like you can with any other WordPress plugin. However, Charitable has an easier built-in process. Please read our documentation on installing and browsing code snippets with WPCode.

Code Snippet Library

All the code snippets we will share in this post exist in the Charitable’s code library at WPCode. You don’t have to use WPCode to take advantage of the code snippets and examples in this library… you can copy and paste various code samples of your choice from the plugin into your text editor or other application. So we recommend you bookmark: Charitable’s code library at WPCode.

Adding A Text Field

In our first example we are going to start off with with a simple textbox to our donation form. Search for “textbox” in Charitable’s code snippet page in the plugin or copy and paste the code below into your code editor.

This code exists here in Charitable’s code library at WPCode.

/**
 * Shows how to add a custom text box in a donation form.
 * In this example, we are adding a text box to collect a special referral code that the admin can read later.
 *
 * This snippet only works in Charitable 1.5 or above.
 *
 */
function wpchar_charitable_register_new_text_field() {
    /**
     * Define a new text field.
     */
	
	if ( ! class_exists("Charitable_Donation_Field" ) ) {
		return;
	};
		
    /* Create the Donation Field instance. */
    $field = new Charitable_Donation_Field(
        'my_custom_field',
        array(
            'label'          => __( 'Referral Code' ), // what text shows up in the donation form.
            'data_type'      => 'meta', 
            'value_callback' => false,
            'donation_form'  => array(
                'type'       => 'text',  // the type of field to show in the donation form (text, checkbox, etc.)
                'required'   => false,   // whether the field is required.
                'show_after' => 'phone', // the field to show this one after.
            ), 
            'admin_form'     => true,
            'show_in_meta'   => true,
            'show_in_export' => true,
            'email_tag'      => array( // the tag to use in email notifications (make false to not add this to tags.
                'description' => __( 'The custom field value' ),
            ),
        )
    );

    /* Register it. */
    charitable()->donation_fields()->register_field( $field );

}

add_action( 'init', 'wpchar_charitable_register_new_text_field' );

Here are the key fields to customize:

  • Label. Change the “My Custom Field” text within the quotes to what you want this to say to donors who see this field in the public donation form.
  • donation_form -> type. This is the type of donation field (text, select, checkbox, datepicker etc.). See our documentation for a full list of supported donation field types.
  • donation_form -> required. If you want this field to be required, set it to true.
  • email_tag. If you want to include the value entered into this field in your email with an email tag in Charitable, add a description here so you can see it appear in the email settings. By default, Charitable uses the key value as the tag (‘my_custom_field’ in this case).

Once this code (via the Charitable snippet screen or by copy and pasting the code) is in WPCode, make sure you give it a descriptive title, make sure the code type is “PHP snippet”, and that you’ve selected auto-insert/run everywhere. Make the snippet active/enabled.

One this is active, visit a donation form (either generated automatically by Charitable or via a shortcode).

You should see something like this:

Congrats! You’ve added your referral code textbox. 🎉

Viewing Custom Data In A Donation

As a reminder, if you have “admin_form” true in your snippet you can view this information in any donation edit screen. If “show_in_export” was left true in the snippet above, you should also see this value exported in the CSV donation data in Charitable as well.

Looking Ahead

If you are a developer or comfortable with adding the code above you should check out our Charitable_Donation_Field documentation and the Donation Fields API for additional and deeper customization… and don’t forget to browse Charitable’s code library at WPCode.

Please let us know if you want any posts or documentation upon a particular subject and feel free to reach out to support! We would love to hear feedback!

author avatar
David Bisset Project Manager
David is the project manager of Charitable since 2022. David works with several non-profits (one operated by his wife) along with managing and developing features, support, and marketing for Charitable. Has been with WordPress since 2006 and has been lead organizer of multiple conferences, events, and meetups.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. We only recommend products that we believe will add value to our readers.

Leave a Reply

Your email address will not be published. Required fields are marked *

Get free tips and resources right in your inbox, along with 60,000+ others

Join our Newsletter

We won’t spam you. We only send an email when we think it will genuinely help you. Unsubscribe at any time!

Featured Video:

Watch more videos on our YouTube channel.

What's New In Charitable

View The Latest Updates
🔔 Subscribe to get our latest updates
📧 Subscribe to Emails

Email Subscription

Join our Newsletter

We won’t spam you. We only send an email when we think it will genuinely help you. Unsubscribe at any time!

automation Improvement

🔌 Charitable Meets Zapier: Connect to 7,000+ Apps and Automate Your Fundraising

Tired of manually copying donation data into accounting sheets or tracking down new donor signups? Put your administrative tasks on autopilot. Charitable is now officially on Zapier, giving you a powerful, no-code way to plug your fundraising directly into the rest of your favorite tools.

Every donation, donor signup, and campaign milestone can now trigger an automated workflow seamlessly.

What’s New:

♾️ Connect to 7,000+ Apps: Bridge your Charitable campaigns with everyday software like Google Sheets, QuickBooks, Slack, Mailchimp, HubSpot, Notion, Airtable, and thousands more.

⚡ 12 Powerful Triggers: Build deep workflows using smart automation triggers covering the entire donation lifecycle—including New Donation, New Donor, Subscription Cancelled, and Campaign Goal Reached.

📋 Pre-Built Action Templates: Get started in three minutes or less with our pre-made template combinations, like automatically logging new donations straight into a Google Sheet or firing custom donor welcome emails through Gmail.

🚫 Zero Code Needed: No complex webhooks or custom PHP scripts required. Just pick your trigger, choose your app, map your fields, and let Zapier handle the heavy lifting.

Ready to save hours of admin time? Grab Charitable Pro with the Automation Connect addon today and launch your first Zap!

author avatar
David Bisset Project Manager
David is the project manager of Charitable since 2022. David works with several non-profits (one operated by his wife) along with managing and developing features, support, and marketing for Charitable. Has been with WordPress since 2006 and has been lead organizer of multiple conferences, events, and meetups.
Improvement Payments

🚀 Introducing PayPal Commerce: One Connection, Six Ways to Donate

Donors expect modern, flexible payment options when they support a cause. If they don’t see their preferred method on your donation form, they often disappear without a word. With PayPal Commerce, we are bringing a completely modernized checkout experience right to your campaigns.

Enjoy a single integration that upgrades your forms, makes giving seamless, and helps you capture every single donation.

What’s New:

🔌 One-Click Connection: Skip messy API keys and developer docs. Simply click “Connect with PayPal,” sign in to your business account, and your modern form is live in under five minutes.

💳 Six Ways to Give: Give your supporters instant access to PayPal balance, Venmo (US), Pay Later financing, major credit/debit cards, Apple Pay (Safari), and Google Pay (Chrome) all from the exact same form.

🔄 Flexible Recurring Giving: Fully supports monthly giving. Choose between the PayPal Subscriptions API (handled automatically on PayPal’s end) or Vault + Cron (handled securely right on your site).

💬 Friendly Error Recovery: No more confusing browser alerts. If a payment is declined, donors see plain-language, inline messages that guide them on how to fix the issue and complete their gift.

Ready for PayPal, modernized? Update to Charitable Pro 1.8.15+ (or Charitable Lite 1.8.11+) and connect your account today!

author avatar
David Bisset Project Manager
David is the project manager of Charitable since 2022. David works with several non-profits (one operated by his wife) along with managing and developing features, support, and marketing for Charitable. Has been with WordPress since 2006 and has been lead organizer of multiple conferences, events, and meetups.
Campaigns New

⏳ Campaign Countdown: Drive Urgency and Lift Donations

Urgency is one of the most powerful tools in fundraising! Meet Campaign Countdown—a live, real-time timer built to turn procrastination into immediate generosity.

campaign_countdown_animation

What’s New:

⏱️ Live, Real-Time Urgency: Beautifully track days, hours, minutes, and seconds down to your campaign’s deadline w/ live-updating visual countdowns.

🎨 Tailored to Your Look: Choose between Boxed bordered tiles or a clean, single-line Inline display. Match your theme instantly with font and deep color controls.

🛠️ Place it Anywhere: Drop the countdown anywhere you like using the Campaign Builder field, a dedicated Gutenberg block, or a simple shortcode.

🚨 Smart Expiry Actions: Total control over the end state—choose to automatically replace the timer with a custom message, freeze it at zero, and more.

author avatar
David Bisset Project Manager
David is the project manager of Charitable since 2022. David works with several non-profits (one operated by his wife) along with managing and developing features, support, and marketing for Charitable. Has been with WordPress since 2006 and has been lead organizer of multiple conferences, events, and meetups.
Improvement Migrations

↔️ Importing From GiveWP, Donorbox, GiveButter… even CSV!

Whether you’re migrating from another platform or consolidating your records, moving your data to Charitable is now faster and more flexible than ever. We’ve streamlined the process so you can bring over your entire fundraising history in just a few clicks.

🔄 Native GiveWP, Donorbox, & GiveButter Support: Switching from a major platform? Our dedicated migration tools handle the heavy lifting, automatically mapping your donors and donations directly into Charitable—no technical skills required.

📂 Universal CSV Import: Moving from a custom system or a specialized CRM? If you can export it to a CSV, you can import it here. Our smart mapping tool lets you align your columns to Charitable fields like names, emails, phone numbers, and addresses in seconds.

Instant Donor Profiles & Custom Tags: Automatically create rich donor profiles and bring in custom tags to keep your data organized. Segment and engage your supporters from day one with a clean, professional database structure.


Ready to make the switch?

Check out our GiveWP Migration Guide

Learn more about our Import Tools

author avatar
David Bisset Project Manager
David is the project manager of Charitable since 2022. David works with several non-profits (one operated by his wife) along with managing and developing features, support, and marketing for Charitable. Has been with WordPress since 2006 and has been lead organizer of multiple conferences, events, and meetups.
Improvement Payments

💳 New Braintree Features For Your European Donors

With the release of Braintree addon version 1.3.0, you can now empower your European donors with the payment methods they trust and prefer, making giving seamless for international supporters.

🌍 Six New European Payment Methods: Support popular local options like iDEAL (Netherlands), Bancontact (Belgium), BLIK (Poland), and more to meet donors where they are.

⚡ Frictionless Donor Experience: These bank-based methods allow donors to authenticate directly with their own bank in a secure popup… no credit card numbers required.

⚙️ Automatic Currency Sync: No complex setup needed. The builder automatically displays the correct payment buttons based on your site’s currency (EUR or PLN), ensuring a relevant experience for every visitor.

author avatar
David Bisset Project Manager
David is the project manager of Charitable since 2022. David works with several non-profits (one operated by his wife) along with managing and developing features, support, and marketing for Charitable. Has been with WordPress since 2006 and has been lead organizer of multiple conferences, events, and meetups.