• Resolved timeagency

    (@timeagency)


    Hi i would like to know how i can get the full list of groups with their ids.
    is there a function or something else?
    Thanks in advance

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter timeagency

    (@timeagency)

    ok, I figured it out by myself.
    Basically going into the functions i got into get_group_tree() and get_group_tree() functions and starting from that i created this:

    function load_checkbox_field_choices( $field ) {
    
        // reset choices
        global $wpdb;
        $group_table = _groups_get_tablename( 'group' );
        $root_groups = $wpdb->get_results( "SELECT group_id FROM $group_table WHERE parent_id IS NULL" );
        $group = array();
        foreach($root_groups as $gruppo){
            $grouped = Groups_Group::read( $gruppo->group_id );
            $group[$grouped->group_id] = $grouped->name;
        }
    
        $field['choices'] = $group;
    
        // return the field
        return $field;
    
    }

    I hope i helped someone.
    If anyone has a more “good looking” code I’m gladly to see it.

    Hey there,

    That’s great, I’m glad you worked this out.

    Kind regards,
    George

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘List of Groups’ is closed to new replies.