Created
March 19, 2019 01:35
-
-
Save ericnicolaas/1012fe60a41b1080a8f8d43e7a647399 to your computer and use it in GitHub Desktop.
Show organization name instead of donor name
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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