Auto-remove from child groups

Hi,

We are using Groups + Groups Restrict Categories + WooCommerce Integration + Learn Dash to manage delivery of training courses, and I am try to figure out how to remove users from a group when they self join another group.

Essentially, “premium members” should have the ability to enroll in any course, but can only access one course at a time. My theory is to join “premium members” to a parent group that allows them to enroll in any course. Then, when they enroll in a course they are added to a child group that has access to that specific course (a course is a custom post type).

This works fine for the first iteration, but for subsequent course enrollments there needs to be a way to automatically remove them from the other child groups.

Thanks!

Justin H.


Comments

One response to “Auto-remove from child groups”

  1. Hi Justin,
    you could use the “groups_created_user_group” action to remove the user from the other groups.
    Something like this:
    add_action( 'groups_created_user_group', 'my_groups_created_user_group', 10, 2 );
    function my_groups_created_user_group( $user_id, $group_id ) {
    .....
    }

    cheers

Share