Set New User Role

/** * Set the role of users who register through the Charitable * registration form shortcode. * * @param array $values * @return array $values */ function ed_charitable_set_user_registration_role( $values ) { if ( array_key_exists( ‘role’, $values ) ) { return…Continue reading

Custom Registration Fields

/** * Add fields to the registration form. * * @param array $fields * @return array */ add_filter( ‘charitable_user_registration_fields’, function( $fields ) { /* Add a text field. */ $fields[‘text_field’] = [ ‘type’ => ‘text’, ‘label’ => ‘My Text Field’,…Continue reading

Add Individual Category Tag Columns

/** * By default, Charitable shows a “Campaign Categories” column in the * donations export, which lists the names of the categories that the * campaign is in. * * In some cases, it may be more helpful to show…Continue reading

Add Progress Bar Before Summary

/** * Add a progress bar to the individual campaign pages. */ function en_add_progress_bar_before_summary() { add_action( ‘charitable_campaign_content_before’, ‘charitable_template_campaign_progress_bar’, 5 ); } add_action( ‘after_setup_theme’, ‘en_add_progress_bar_before_summary’, 11 );Continue reading

Add Extra Column

/** * This example shows how to remove columns from the Donations export. * * Since this relies on the Donation Fields API, it requires Charitable 1.5+. * * For a way of doing this on older versions of Charitable,…Continue reading

Add Field To Set Custom Page As Donation Page

/** * Create a new campaign field allowing to select the page where donations are made. */ add_action( ‘init’, function() { $campaign_field = new Charitable_Campaign_Field( ‘donation_page’, array( ‘label’ => ‘Donation Page’, ‘data_type’ => ‘meta’, ‘admin_form’ => array( ‘type’ => ‘select’,…Continue reading

Add Campaign Creator Name Donation Export

/** * In this example, the campaign creator’s name is added to the Donations * export, so it’s easy to see who created the campaign that received the * donation when exporting the donations. */ add_action( ‘init’, function() { $field…Continue reading

Remove Donor Count

/** * An example showing how to do this is provided at https://github.com/Charitable/library/blob/master/general/unhook-default-charitable-template-functions.php. * * It is a more general example that illustrates how to unhook any default Charitable template function. * * @see https://github.com/Charitable/library/blob/master/general/unhook-default-charitable-template-functions.php */Continue reading

Remove Donation Columns

/** * This example shows how to remove columns from the Donations export. * * Since this relies on the Donation Fields API, it requires Charitable 1.5+. * * For a way of doing this on older versions of Charitable,…Continue reading

Round Percent Donated To Whole Number

/** * Display percent donated as rounded whole number. * * @param string $return * @param int $percent * @return string */ function ed_round_percent_donated_to_whole_number( $return, $percent ) { return ceil( $percent ) . ‘%’; } add_filter( ‘charitable_percent_donated’, ‘ed_round_percent_donated_to_whole_number’, 10, 2…Continue reading