Use Page Template For Campaigns

/** * Instead of using the Post template for campaigns, use the Page template as a fallback. * * @param string $template * @return string $template */ function ed_campaigns_use_page_template( $template ) { global $wp_query; if ( is_main_query() && is_singular( ‘campaign’…Continue reading

Remove Stats Summary Block

/** * Remove the campaign summary block (funds raised, number of donors, etc). */ function en_remove_campaign_summary_block() { remove_action( ‘charitable_campaign_content_before’, ‘charitable_template_campaign_summary’, 6 ); // If you still want to show a Donate button, uncomment the line below. // add_action( ‘charitable_campaign_content_before’, ‘charitable_template_donate_button’,…Continue reading

Add Campaign Raised Summary

/** * Add a short summary after the donation details showing the funds raised by each campaign. */ function ed_add_campaign_stats_to_receipt( $donation ) { $campaigns = $donation->get_campaign_donations(); ob_start(); printf( ‘ %s ‘, __( ‘Campaign Stats’ ) ); foreach ( $campaigns as…Continue reading

Change Donor Count

/** * In this example, the donor count is changed for a specific campaign * with an ID of 123. The donor count is incremented by 45. */ add_filter( ‘charitable_campaign_donor_count’, function( $count, $campaign ) { if ( 123 === $campaign->ID…Continue reading

Add Campaign Link

/** * Add a link back to the campaign from the donation receipt. */ function ed_add_campaign_link_to_receipt( $donation ) { $campaigns = $donation->get_campaign_donations(); // We’re just linking to the first campaign. $campaign_donation = current( $campaigns ); ob_start(); ?>Continue reading

Allow Admin Access

/** * By default, Charitable disables admin access for users * who do not have one of the `edit_posts`, * `manage_charitable_settings`, or `edit_products` * capabilities. * * The code below enables access for logged in users who do * not…Continue reading

Show Admin Bar

/** * By default, Charitable hides the admin bar from users * who do not have one of the `edit_posts`, * `manage_charitable_settings`, or `edit_products` * capabilities. * * The code below shows the admin bar for logged in users who…Continue reading

Bulk Update Campaign End Dates

/** * Bulk-update the end date for all campaigns. */ add_action( ‘admin_init’, function() { // Retrieve all campaigns. $campaigns = Charitable_Campaigns::query( [ ‘posts_per_page’ => -1, ‘post_status’ => ‘any’, ‘fields’ => ‘ids’, ] ); foreach ( $campaigns->posts as $campaign_id ) {…Continue reading