Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to display my groups instead of all groups from a dropdown


  • tccdeveloper05
    Participant

    @tccdeveloper05

    Wordpress Version: 5.8
    Buddypress Version: 9.1.1
    Link: no link because this is only from localhost.

    So i have these lines of code which displays all exisiting groups from the website and if i select one, it will link/integrate it to a course i selected (LMS).

    <?php
    $groups = groups_get_groups(array(‘show_hidden’ => true));
    $attached_group = (array) \TUTOR_BP\BuddyPressGroups::get_group_ids_by_course(get_the_ID());

    ?>
    <div class=”tutor-option-field-row”>
    <div class=”tutor-option-field-label”>
    <label for=””>
    <?php _e(‘BuddyPress Groups’, ‘tutor-pro’); ?>
    </label>
    </div>
    <div class=”tutor-option-field tutor-field-number”>
    <select name=”_tutor_bp_course_attached_groups[]” class=”tutor_select2″ multiple=”multiple”>
    <?php
    foreach ($groups[‘groups’] as $group){
    $selected = in_array($group->id, $attached_group) ? ‘selected=”selected”‘ : ”;
    echo “<option value='{$group->id}’ {$selected} > {$group->name} </option>”;
    }
    ?>
    </select>
    <p class=”desc”><?php _e(‘Assign this course to BuddyPress Groups’, ‘tutor-pro’); ?></p>
    </div>
    </div>

    However from the <select> options i only want to display the groups i have created. how to do this? any help will be appreciated!

  • You must be logged in to reply to this topic.
Skip to toolbar