Hooks

Class adds additional missing hooks from Learndash

Description

Source

File: bp-integrations/learndash/buddypress/Hooks.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
class Hooks
{
    /**
     * Constructor
     *
     * @since BuddyBoss 1.0.0
     */
    public function __construct()
    {
        add_action('bp_ld_sync/init', [$this, 'init']);
    }
 
    /**
     * Add actions once integration is ready
     *
     * @since BuddyBoss 1.0.0
     */
    public function init() {
        // add some helpful missing hooks
        add_action( 'groups_create_group', [ $this, 'groupCreated' ] );
        add_action( 'groups_update_group', [ $this, 'groupUpdated' ] );
        add_action( 'groups_before_delete_group', [ $this, 'groupDeleting' ] );
        add_action( 'groups_delete_group', [ $this, 'groupDeleted' ] );
 
        // admin
        add_action( 'bp_group_admin_edit_after', [ $this, 'groupUpdated' ] );
 
        add_action( 'groups_member_after_save', [ $this, 'groupMemberAdded' ] );
        add_action( 'groups_member_after_remove', [ $this, 'groupMemberRemoved' ] );
    }
 
    /**
     * Sub action when bp gorup is created
     *
     * @since BuddyBoss 1.0.0
     */
    public function groupCreated($groupId)
    {
        do_action('bp_ld_sync/buddypress_group_created', $groupId);
    }
 
    /**
     * Sub action when bp gorup is updated
     *
     * @since BuddyBoss 1.0.0
     */
    public function groupUpdated($groupId)
    {
        do_action('bp_ld_sync/buddypress_group_updated', $groupId);
    }
 
    /**
     * Sub action before bp gorup is deleted
     *
     * @since BuddyBoss 1.0.0
     */
    public function groupDeleting($groupId)
    {
        do_action('bp_ld_sync/buddypress_group_deleting', $groupId);
    }
 
    /**
     * Sub action after bp gorup is deleted
     *
     * @since BuddyBoss 1.0.0
     */
    public function groupDeleted($groupId)
    {
        do_action('bp_ld_sync/buddypress_group_deleted', $groupId);
    }
 
    /**
     * Sub action when a member is added to bp group, based on type
     *
     * @since BuddyBoss 1.0.0
     */
    public function groupMemberAdded($groupMemberObject)
    {
        if (! $groupMemberObject->is_confirmed) {
            return false;
        }
 
        $groupId = $groupMemberObject->group_id;
        $memberId = $groupMemberObject->user_id;
 
        if ($groupMemberObject->is_banned) {
            return do_action('bp_ld_sync/buddypress_group_member_banned', $groupId, $memberId, $groupMemberObject);
        }
 
        if ($groupMemberObject->is_admin) {
            return do_action('bp_ld_sync/buddypress_group_admin_added', $groupId, $memberId, $groupMemberObject);
        }
 
        if ($groupMemberObject->is_mod) {
            return do_action('bp_ld_sync/buddypress_group_mod_added', $groupId, $memberId, $groupMemberObject);
        }
 
        return do_action('bp_ld_sync/buddypress_group_member_added', $groupId, $memberId, $groupMemberObject);
    }
 
    /**
     * Sub action when a member is deleted to bp group, based on type
     *
     * @since BuddyBoss 1.0.0
     */
    public function groupMemberRemoved($groupMemberObject)
    {
        $groupId = $groupMemberObject->group_id;
        $memberId = $groupMemberObject->user_id;
 
        if ($groupMemberObject->is_admin) {
            return do_action('bp_ld_sync/buddypress_group_admin_removed', $groupId, $memberId, $groupMemberObject);
        }
 
        if ($groupMemberObject->is_mod) {
            return do_action('bp_ld_sync/buddypress_group_mod_removed', $groupId, $memberId, $groupMemberObject);
        }
 
        return do_action('bp_ld_sync/buddypress_group_member_removed', $groupId, $memberId, $groupMemberObject);
    }
}

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.