Home / Admin / Add Donor Comments To Donor Wall
Duplicate Snippet

Embed Snippet on Your Site

Add Donor Comments To Donor Wall

This will display a donor comment with a donor's donation information on the donor wall in Charitable. Note that the donor wall (at the time of this writing) wasn't designed to display large amounts of information, so this is merely used as a guide.

Code Preview
php
<?php
add_action('charitable_donor_loop_after_donor', 'example_charitable_donor_loop_after_donor', 10, 2 );
function example_charitable_donor_loop_after_donor( $donor, $view_args ) {
	$user_id = $donor->get_user_id();
	$campaign_id = ! empty ( $view_args['campaign'] ) ? $view_args['campaign'] : 0;
	if ( 0 === $campaign_id ) {
		return;
	}
   $args = array(
        'user_id'   => $user_id,
        'post_id'   => $campaign_id,
        'status'    => 'approve',
        'number'    => 1,
        'orderby'   => 'comment_date_gmt',
        'order'     => 'DESC'
    );
    $comments = get_comments($args);
    if (!empty($comments)) {
        // Output comment content - you might want to alter this to allow additional HTML.
        echo esc_html($comments[0]->comment_content);
    } else {
       // Output nothing.
    }
}

Comments

Add a Comment