XProfile: Return early when no contributors to avoid error.

This commit is contained in:
Ian Dunn 2019-10-29 10:08:26 -07:00
parent bc867a344e
commit f409dbd3a6
No known key found for this signature in database
GPG key ID: 99B971B50343CBCB

View file

@ -46,14 +46,19 @@ function get_xprofile_contribution_data( array $user_ids ) {
* *
* @param int $pledge_id * @param int $pledge_id
* *
* @return array * @return array|false
*/ */
function get_aggregate_contributor_data_for_pledge( $pledge_id ) { function get_aggregate_contributor_data_for_pledge( $pledge_id ) {
$contributors = Contributor\get_contributor_user_objects(
// TODO set to 'publish' when finished testing. // TODO set to 'publish' when finished testing.
Contributor\get_pledge_contributors( $pledge_id, 'pending' ) $contributor_posts = Contributor\get_pledge_contributors( $pledge_id, 'pending' );
);
$user_ids = wp_list_pluck( $contributors, 'ID' ); // All of their contributors might have declined the invitation and had their posts deleted.
if ( ! $contributor_posts ) {
return false;
}
$contributor_users = Contributor\get_contributor_user_objects( $contributor_posts );
$user_ids = wp_list_pluck( $contributor_users, 'ID' );
$data = get_xprofile_contribution_data( $user_ids ); $data = get_xprofile_contribution_data( $user_ids );