Closed elievischel closed 2 years ago
Thanks for the suggestion, you seem to try to obtain what is already provided via the group_ids_deep
property of the Groups_User object:
$groups_user = new Groups_User( get_current_user_id() );
// get group ids (user is direct member or by group inheritance)
$user_group_ids_deep = $groups_user->group_ids_deep;
I wanted to implement and share a functionnality that a lot of users asked on the wordpress comments :
the possibility to retrieve all the children groups below a current group we are currently assigned to. parent child1 grandchild1 grandchild2 child2
if the user is only affected to the parent group, the function get_below_group_ids_from_user($user_id) will return the ids from all the descendants (child1, child2, grandchiild1, grandchild2)
maybe we need to rename these functions, but it helped me a lot.