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
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.