Charitable Blog

Everything you need to know about Charitable and our team.

How to Add Checkboxes to Donation Forms

How to Add Checkboxes To Your 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 a few examples of adding custom fields with code snippets.

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.

Remember that once is added (via the Charitable snippet screen or by copy and pasting the code) in WPCode you need 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. Here’s an example:

Adding A Checkbox

The code snippet for a single checkbox is not that different from a text box. Notice the use of “checkbox” as the “type”. You can also view this code on our WPCode snippet library.

/**
 * Collect a checkbox field in the donation form.
 *
 * This snippet only works in Charitable 1.5 or above.
 *
 * Related examples:
 *
 * @see Register a text field (detailed example) - https://github.com/Charitable/library/blob/master/donation-form/register-new-donation-field-1.5.php
 * @see Register multiple fields - https://github.com/Charitable/library/blob/master/donation-form/register-multiple-donation-fields.php
 * @see The old way to add fields - https://github.com/Charitable/library/blob/master/donation-form/legacy/add-checkbox-field-to-donation-form.php
 */
function wpchar_charitable_register_new_checkbox_field() {
	
	if ( ! class_exists("Charitable_Donation_Field" ) ) {
		return;
	};
	
    /**
     * Define a new checkbox field.
     */
    $field = new Charitable_Donation_Field( 'new_checkbox_field', array(
        'label' => __( 'New Checkbox Field', 'charitable' ),
        'data_type' => 'user',
        'donation_form' => array(
            'type' => 'checkbox',
            'show_before' => 'phone',
            'required'   => false,
        ),
        'admin_form' => true,
        'show_in_meta' => true,
        'show_in_export' => true,
        'email_tag' => array(
            'description' => __( 'The new checkbox field' , 'charitable' ),
        ),
    ) );

    /**
     * Register the checkbox field.
     */
    charitable()->donation_fields()->register_field( $field );
}

add_action( 'init', 'wpchar_charitable_register_new_checkbox_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) and you should see your checkbox. 🎉

Multiple Checkboxes

Adding multiple checkboxes requires adding “options” to the snippet and changing the type to “multi-checkbox”.

The below script adds MULTIPLE CHECKBOXES (using “multi-checkbox” and can also be found in our WPCode snippet library and you can also view another more real world examples of using checkboxes that add a bit more logic, like this example of adding a donation receipt opt out checkbox.

/**
 * Add three checkboxes (the same group) in the donation form.
 *
 * This snippet only works in Charitable 1.5 or above.
 *
 */
function wpchar_charitable_register_new_checkboxes_field() {
	
    if ( ! class_exists("Charitable_Donation_Field" ) ) {
	return;
    };
	
    /**
     * Define a new checkbox field.
     */
    $field = new Charitable_Donation_Field( 'new_checkboxes_field', array(
        'label' => __( 'New Checkboxes Field', 'charitable' ),
        'data_type' => 'user',
        'donation_form' => array(
            'type' => 'multi-checkbox',
            'show_before' => 'phone',
            'required'   => false,
            'options' => array (
                 'option_1_value' => 'Option One',
                 'option_2_value' => 'Option Two',
                 'option_3_value' => 'Option Three',
	     ),
        ),
        'admin_form' => true,
        'show_in_meta' => true,
        'show_in_export' => true,
        'email_tag' => array(
            'description' => __( 'The new checkbox field' , 'charitable' ),
        ),
    ) );

    /**
     * Register the checkbox field.
     */
    charitable()->donation_fields()->register_field( $field );
}

add_action( 'init', 'wpchar_charitable_register_new_checkboxes_field' );

This should appear like this in your donation form:

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!

GiveWP Migrations New

White Glove Migration Service for GiveWP

Thinking about switching your fundraising platform from GiveWP to Charitable, but don’t want to risk losing your data or handle a complex technical setup yourself? Charitable’s White Glove Migration Service features:

👥 Flawless Donor Mapping: Safely transfer your entire supporter database with zero data loss.

📊 Complete Financial History: Meticulously preserve every historical transaction for continuous, accurate reporting.

🔄 Seamless Recurring Giving: Safely transfer active sustaining subscriptions without disrupting your incoming revenue or requiring your donors to update their information.

💳 Zero Gateway Disruptions: Keep using Stripe, PayPal, or any other GiveWP-compatible processor you already love.

🚀 Expert Technical Setup: Relax while our team handles the heavy lifting to install and configure your forms—plus, qualifying users get a full year of Charitable Pro completely free.

Visit this page to learn 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.
automation Improvement

📢 New Feature Alert: Automation Connect 2.0 Is Here! 🚀

Thinking about connecting your fundraising data to tools like Mailchimp, Slack, or Google Sheets, but don’t want to hire a developer or write custom code? Charitalbe’s new automation addon has:

⚡ 17 Event Triggers: Instantly fire webhooks for a donor’s first gift, renewal payments, or reached campaign milestones.

🎯 Smart Conditional Logic: Use powerful AND/OR logic across 11 fields to only send data when it meets your exact criteria, like newsletter opt-ins.

📊 Custom Payload Control: Select from 80+ clean data fields across donor, donation, and campaign metadata so your apps get exactly what they need.

🚀 Pre-Built Platform Templates: Skip the setup from scratch with ready-to-go templates for Zapier, Make.com, n8n, HubSpot, and Slack.

🛡️ Reliable Developer Tools: Power your workflows with signed HMAC-SHA256 payloads, complete WordPress filters, and automatic retry logs.

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.
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.