• Resolved gabessdsp

    (@gabessdsp)


    I found a couple of other topics on this so I’m not sure if something changed but it does not appear to work.

    I installed code snippets and this is the code I have in it:

      function ed_unhook_default_template_functions() {
    
         remove_action( 'charitable_campaign_content_loop_after', 'charitable_template_campaign_loop_donation_stats', 8 );
    
    }
    add_action( 'after_setup_theme', 'ed_unhook_default_template_functions', 11 );

    Snippet is set to run everywhere. Yet on the donation page: https://stoptransource.org/index.php/campaigns/citizens-to-stop-transource/

    I still see the total amount donated and the # of donors. I want to hide both of those things.

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi @gabessdsp,

    You nearly had it! Here’s an updated version with those other bits removed as well:

    function ed_unhook_default_template_functions() {
    
        remove_action( 'charitable_campaign_content_loop_after', 'charitable_template_campaign_loop_donation_stats', 8 );
        remove_action( 'charitable_campaign_summary', 'charitable_template_campaign_percentage_raised', 4 );
        remove_action( 'charitable_campaign_summary', 'charitable_template_campaign_donation_summary', 6 );
        remove_action( 'charitable_campaign_summary', 'charitable_template_campaign_donor_count', 8 );
    
    }
    add_action( 'after_setup_theme', 'ed_unhook_default_template_functions', 11 );
    

    Cheers,
    Eric

    Thread Starter gabessdsp

    (@gabessdsp)

    Eric thank you so much!

    No worries @gabessdsp! If you haven’t already, we’d love a quick review of Charitable ??

    Cheers,
    Eric

    Hi @ericdaams,

    Is there something that could be included in this snippet that would only apply this to “Finished” campaigns and keep the stats on “Active” campaigns?

    Hi @ccostner,

    The snippet above won’t work for that. I don’t have something out of the box for that, but this example comes closest:

    https://github.com/Charitable/library/blob/master/campaigns/remove-stats-summary-block-from-specific-campaign.php#L9-L16

    You would need to replace the highlighted section with a check for whether the campaign is finished; if it is, return before displaying the template. Something like this might work:

    if ( ! $campaign->can_receive_donations() ) {
        return;
    }
    

    That will remove the stats from any campaign that cannot currently receive donations. That includes finished campaigns but also campaigns that are not published, like draft or pending campaigns.

    Cheers,
    Eric

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Hiding the Amount Raised’ is closed to new replies.