Reports::removePointsColumnIfNotAssigned( $columns,  $args )

Remove the points column if all courses doesn’t have points

Description

Source

File: bp-integrations/learndash/buddypress/Reports.php

	public function removePointsColumnIfNotAssigned($columns, $args)
	{
		$shouldRemove = false;

		if ($args['course']) {
			$shouldRemove = '' === get_post_meta($args['course'], 'course_points', true);
		} else {
			$groupCourses = bp_ld_sync('buddypress')->courses->getGroupCourses($args['group']);
			$shouldRemove = array_sum(array_map(function($course) use ($args) {
				return get_post_meta($args['course'], 'course_points', true) ?: 0;
			}, $groupCourses)) > 0;
		}

		if (! in_array($args['step'], ['all', learndash_get_post_type_slug('course')])) {
			unset($columns['points']);
		}

		if ($shouldRemove) {
			unset($columns['points']);
		}

		return $columns;
	}

Changelog

Changelog
Version Description
BuddyBoss 1.0.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.