• Resolved johnmontfx

    (@johnmontfx)


    I have my groups tree set up as follows:

    ParentGroup
    -ChildGroup1
    -ChildGroup2

    To make things more straightforward in coding, I want to be able to check if members are in a parent group and then have more granular capabilities in the child groups. However, the following code doesn’t work for users who are in the child groups:

    $is_forum_member = 'false';
    $group = Groups_Group::read_by_name( 'ParentGroup' ) ;
    $is_forum_member = Groups_User_Group::read( get_current_user_id() , $group->group_id );

    $is_forum_member returns false for users who are in either ChildGroup1 or ChildGroup2

    Is there a function where this will work? I can’t seem to find it in the API docs.

    https://ww.wp.xz.cn/plugins/groups/

Viewing 1 replies (of 1 total)
  • Plugin Author Kento

    (@proaktion)

    $u = new Groups_User( get_current_user_id() );

    $u->group_ids_deep provides all group ids of those that the user belongs to
    $->groups_deep provides the Groups_Group objects

Viewing 1 replies (of 1 total)

The topic ‘API function which checks for parent group?’ is closed to new replies.