Helpers

Class misc helper functions

Description

Source

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

19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
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.