Charitable Code Snippet library
This is a library of code snippets designed to help end users and theme or plugin developers.
How to use the code snippets
If you are new to PHP or WordPress development, we recommend adding these code snippets using the Code Snippets plugin. This allows you to add the code directly within your WordPress dashboard.
For those a little more familiar with WordPress development, you can use the snippets to create simple standalone plugins. Read the WordPress documentation about creating a plugin.
Alternatively, you could add the snippets directly to your theme or child theme's functions.php
file.
Contributing a snippet
We welcome and encourage everyone to submit their code snippets. If you would like to submit your snippet, please fork the repository and then create a pull request.
Directory
General
- Unhook default Charitable template functions
- Add an "Hours" currency
- Add the User Dashboard menu at the top of all User Dashboard pages
Editing Forms
- Remove form fields
- Change form fields
- Change the labels of form fields
- Change whether a form field is required
- Add HTML before form fields
- Add HTML after form fields
- Add a description/paragraph field to a form
Donation form
- Add a checkbox field to the donation form
- Add a select field to the donation form
- Add an opt-out for receiving the donation receipt
- Change State field to Province
- Collect National ID number
- Make the donor address fields required
- Remove donation form fields
- Remove login form
- Set the minimum donation amount
- Add campaign title as a header
- Display a specific donation form
- Add a shortcode for displaying donation forms
- Move donor details section to end of form, after payment form
- Show the Offline payment instructions in the donation form
Donation receipt
- Display a link back to the campaign from the donation receipt
- Display a summary of the amount raised for the campaign
- Set a custom donation receipt page
- Set a custom donation receipt page for offline donations
Donations
- Treat Pending donations as "Approved" donations
- Automatically mark Offline donations as Paid
- Add a Donate button with modal to your template
Emails
- Add email headers
- Copy the donation receipt to the website admin
- Send donation notifications to admin for Offline donations that are Pending
- Send donation receipt to customer for Offline donations that are Pending
- Remove campaign name from donation summaries in emails
- Add a custom campaign field to display in emails
- Add a custom donation field to display in emails
- Add the offline payment instructions to donation emails
Campaigns
- Use the Page template for campaigns
- Add featured image to the top of the campaign
- Remove campaign summary block
- Remove campaign summary block from a specific campaign
- Remove the donor count
- Remove the donor count from a specific campaign
- Add a progress bar before the campaign summary block
- Move the campaign summary block below the Extended Description
- Remove the campaign descriptions from the [campaigns] output
- Add a custom field to the [campaigns] output
- Add a Read More link to the [campaigns] output
- Change the Thumbnail size in the [campaigns] output
- Disable description text santization
- Round the percentage donated to a whole number
- Change the amount shown as donated to a particular campaign
- Change the campaign slug base
- Change the campaign rewrite rules to disable the
with_front
setting - Add a "Campaigns" menu tab to the WordPress dashboard
Notifications
Login form
- Change the arguments passed to the login form (uses
wp_login_form()
) - Redirect to the previous page after logging in
Profile form
Registration form
- Send emails to the new user and admin after a user registers
- Redirect the user to a custom page after registration
- Set the role of new users
Styles
Export
Payment Gateways: PayPal
- Collect shipping information in PayPal
- Set a custom item name for donations in PayPal
- Set the locale in PayPal
Payment Gateways: Offline
- Show the Offline payment instructions in the donation form
- Set a custom donation receipt page for offline donations
- Automatically mark Offline donations as Paid
- Send the Campaign Creator Donation Notification for Offline donations when they're pending
- Add the offline payment instructions to donation emails
Payment Gateways: Stripe
Payment Gateways: PayUMoney
Extensions: Charitable Ambassadors
Campaign Form
- Add select field
- Remove all user fields except for the name & email fields
- Add address fields to the "Your Details" section
- Automatically approve campaigns
- Allow ambassadors to edit the goal of an active campaign
- Change the categories & tags fields into dropdown (select) fields
- Remove the categories field
- Remove the organisation field
- Remove the tags field
- Remove the short description field
- Remove the user biography field
- Set default text for full description field
- Set default country for Ambassadors
- Set the default category for new campaign submissions
- Add phone number field
- Change the Campaign Details header
- Change field labels
- Change editable fields to non-editable and vice versa
- Remove the campaign length field and replace with an end date field
- Add user details to funds recipient information
- Automatically set the Suggested Donations and custom donation settings
- Automatically set the campaign parent for all submitted campaigns
- Automatically set the campaign's end date
- Change the PayPal payout details field
- Redirect logged out users to the registration page
- Only allow users to create one campaign
- Prevent users from editing a published campaign
- Add a "Gallery" field to the campaign form and display the gallery on the campaign automatically
- Add a "Terms and Conditions" section to the campaign form
- Redirect to the campaign after submitting the form
- Change the recipient type labels for "Personal Causes" and "Your Organization"
Campaigns
My Campaigns Shortcode
Emails
Extensions: Charitable Easy Digital Downloads Connect
- Add {campaign_donations} email tag
- Add a custom checkout field for specific campaigns
- Show the Easy Digital Downloads gateway used for donations
Extensions: Charitable Recurring Donations
- Change the recurring period to weekly
- Set a fixed recurring donation amount
- Do not send recurring emails for pending donations unless they are offline
Themes: Reach
- Unhook a template
- Add the donate button to campaigns in a grid
- Re-order the social network links
- Move the donate button on the campaign page
- Change the donation page title