BP_REST_Group_Settings_Endpoint::update_courses_fields( WP_REST_Request $request )
Update Group Courses settings.
Description
Parameters
- $request
-
(Required) Request used to generate the response.
Return
(array)
Source
File: bp-groups/classes/class-bp-rest-group-settings-endpoint.php
1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 | protected function update_courses_fields( $request ) { $post_fields = $request ->get_param( 'fields' ); $group_id = $request ->get_param( 'id' ); $group = groups_get_group( $group_id ); buddypress()->groups->current_group = $group ; 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 update the courses group settings options.' , 'buddyboss' ), array ( 'status' => 400, ) ); } if ( empty ( $post_fields ) ) { return array ( 'error' => '' , 'notice' => '' , ); } $generator = bp_ld_sync( 'buddypress' )->sync->generator( $group_id ); if ( array_key_exists ( 'bp-ld-sync-enable' , ( array ) $post_fields ) && empty ( $post_fields [ 'bp-ld-sync-enable' ] ) ) { $generator ->desyncFromLearndash(); } elseif ( array_key_exists ( 'bp-ld-sync-enable' , ( array ) $post_fields ) && ! empty ( $post_fields [ 'bp-ld-sync-enable' ] ) ) { $generator ->associateToLearndash()->syncBpAdmins(); } $notice = __( 'Group settings were successfully updated.' , 'buddyboss' ); return array ( 'error' => '' , 'notice' => $notice , ); } |
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.