Helpers

Class misc helper functions

Description

Source

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

class Helpers
{
	protected $ldGroupMetaKey = '_ld_group_id';

	/**
	 * Determine whether a group has connected ld group
	 *
	 * @since BuddyBoss 1.0.0
	 */
	public function hasLearndashGroup($groupId = null)
	{
		if (! $groupId) {
			return false;
		}

		if (! $ldGroupId = $this->getLearndashGroupId($groupId)) {
			return false;
		}

		if ('publish' !== get_post_status($ldGroupId)) {
			return false;
		}

		return true;
	}

	/**
	 * Get the connected ld group id
	 *
	 * @since BuddyBoss 1.0.0
	 */
	public function getLearndashGroupId($groupId)
	{
		return bp_ld_sync('buddypress')->sync->generator($groupId)->getLdGroupId();
		return bp_learndash_groups_sync_get_associated_ld_group($groupId)->ID;
		return groups_get_groupmeta($groupId, $this->ldGroupMetaKey, true);
	}

	/**
	 * Set the ld group id on a bp grouop
	 *
	 * @since BuddyBoss 1.0.0
	 */
	public function setLearndashGroupId($groupId, $ldGroupId)
	{
		return groups_update_groupmeta($groupId, $this->ldGroupMetaKey, $ldGroupId);
	}

	/**
	 * Remove ld group connection from a bp group
	 *
	 * @since BuddyBoss 1.0.0
	 */
	public function deleteLearndashGroupId($groupId)
	{
		return groups_delete_groupmeta($groupId, $this->ldGroupMetaKey);
	}
}

Changelog

Changelog
Version Description
BuddyBoss 1.0.0 Introduced.

Methods

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.