Set Campaign Thumbnail Size

/** * If you want all campaign thumbnails to have the same size, you can use the * snippet below. Note that images will be hard-cropped, so part of the image * may be cropped out. * * If you…Continue reading

Enable Block Editor For Campaigns

/** * The following code will modify the way the Campaign post type * is set up to so that it uses the block editor instead of the * classic editor. */ add_filter( ‘charitable_campaign_post_type’, function( $post_type_args ) { $post_type_args[‘show_in_rest’] =…Continue reading

Set Default Highlight Colour

/** * NOTE: This snippet will not work in versions of Charitable prior to 1.2. * * Set the default colour used by Charitable. * * @return string */ function en_set_default_highlight_colour() { return ‘#123456’; } add_filter( ‘charitable_default_highlight_colour’, ‘en_set_default_highlight_colour’ );Continue reading

Add Creator Name

/** * Display the campaign creator’s name on the campaign page and in the campaign grid/list. * * @param Charitable_Campaign $campaign The campaign object. */ function ed_charitable_display_campaign_creator_name( Charitable_Campaign $campaign ) { $name = charitable_get_user( $campaign->get_campaign_creator() )->get_name(); ?> Creator:Continue reading

Change State To Province

/** * Change the “State” field into a “Province” field. * * @param array[] $fields * @return array[] */ add_action( ‘init’, function ( $fields ) { $fields = charitable()->donation_fields(); $field = $fields->get_field( ‘state’ ); $field->label = ‘Province’; $field->set( ‘donation_form’, ‘label’,…Continue reading

Make Donor Address Required

/** * Make all address fields required. * * As of Charitable 1.6 the approach below is the recommended way of achieving this. * If you are using an older version of Charitable, see the legacy version below: * *…Continue reading

Add Empty Option To Countries List

/** * In this example we add an empty “Select your country” * option at the start of the list of countries in the * donation form. */ add_action( ‘init’, function() { $fields = charitable()->donation_fields(); $field = $fields->get_field( ‘country’ );…Continue reading

Change Section Headers Per Campaign

/** * Change the section headers in the donation form. * * @param array $fields All the donation form fields. * @return array */ function ed_charitable_change_donation_form_section_headers_per_campaign( $fields, $form ) { if ( 123 === $form->get_campaign()->ID ) { // Section headers…Continue reading

Allow Zero Dollar Donations

/** * Allow people to “donate” $0. */ function ed_charitable_set_minimum_donation_amount() { return 0; } add_filter( ‘charitable_minimum_donation_amount’, ‘ed_charitable_set_minimum_donation_amount’ ); /** * You need to specifically enable $0 donations. */ add_filter( ‘charitable_permit_0_donation’, ‘__return_true’ );Continue reading