BP_REST_Group_Settings_Endpoint::get_courses_fields( integer $group_id )

Get Group course Settings.

Description

Parameters

$group_id

(Required) Group ID.

Return

(mixed|void)

Source

File: bp-groups/classes/class-bp-rest-group-settings-endpoint.php

1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
protected function get_courses_fields( $group_id ) {
    $fields                             = array();
    buddypress()->groups->current_group = groups_get_group( $group_id );
 
    if ( ! function_exists( 'bp_ld_sync' ) || '1' !== bp_ld_sync( 'settings' )->get( 'buddypress.enabled', true ) ) {
        return new WP_Error(
            'bp_rest_invalid_group_setting_nav',
            __( 'Sorry, you are not allowed to see the courses group settings options.', 'buddyboss' ),
            array(
                'status' => 400,
            )
        );
    }
 
    $has_ld_group = bp_ld_sync( 'buddypress' )->sync->generator( $group_id )->hasLdGroup();
 
    $fields[] = array(
        'label'       => esc_html__( 'Group Courses Settings', 'buddyboss' ),
        'name'        => '',
        'description' => esc_html__( 'Create and associate to a LearnDash group, allowing courses and reports to be managed within the group.', 'buddyboss' ),
        'field'       => 'heading',
        'value'       => '',
        'options'     => array(),
    );
 
    $fields[] = array(
        'label'       => esc_html__( 'Yes. I want this group to sync with a LearnDash group.', 'buddyboss' ),
        'name'        => 'bp-ld-sync-enable',
        'description' => '',
        'field'       => 'checkbox',
        'value'       => $has_ld_group,
        'options'     => array(),
    );
 
    return apply_filters( 'bp_rest_group_settings_courses', $fields, $group_id );
}

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.