Skip to content

Instantly share code, notes, and snippets.

@ericnicolaas
Created March 19, 2019 01:35
Show Gist options
  • Save ericnicolaas/1012fe60a41b1080a8f8d43e7a647399 to your computer and use it in GitHub Desktop.
Save ericnicolaas/1012fe60a41b1080a8f8d43e7a647399 to your computer and use it in GitHub Desktop.
Show organization name instead of donor name
<?php
/**
* If you have a custom donation field where donors can
* enter their organization name, you may want to display
* the organization name instead of the donor's name
* in the donor widget/shortcode.
*
* @param string $name The donor's name.
* @param array $view_args A collection of arguments passed to the view.
* This includes the Charitable_Donor instance.
* @rerturn string
*/
add_filter( 'charitable_donor_loop_donor_name', function( $name, $view_args ) {
$organization = $view_args['donor']->get_donor_meta( 'organization' );
if ( ! empty( $organization ) ) {
$name = $organization;
}
return $name;
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment