bp_ps_learndash_course_setup( $fields )
Registers a LearnDash course field in frontend and backend in advance search.
Description
Parameters
- $fields
-
(Required)
Return
(array)
Source
File: bp-core/profile-search/bps-xprofile.php
function bp_ps_learndash_course_setup ($fields) { // check is LearnDash plugin is activated or not. if(in_array('sfwd-lms/sfwd_lms.php', apply_filters('active_plugins', get_option('active_plugins')))){ global $wpdb; $query = "SELECT DISTINCT ID FROM {$wpdb->posts} WHERE post_type = %s AND post_status = %s ORDER BY menu_order"; $courses_arr = $wpdb->get_col( $wpdb->prepare( $query, 'sfwd-courses', 'publish' ) ); $courses = array(); if ( $courses_arr ) : foreach ( $courses_arr as $course ) { $post = get_post( $course ); $courses[ $post->ID ] = get_the_title( $post->ID ); } endif; $f = new stdClass; $f->group = __('LearnDash', 'buddyboss'); $f->id = 'learndash_courses'; $f->code = 'field_learndash_courses'; $f->name = __('Courses', 'buddyboss'); $f->description = __('Courses', 'buddyboss'); $f->type = 'selectbox'; $f->format = bp_ps_xprofile_format('selectbox','learndash_courses'); $f->options = $courses; $f->search = 'bp_ps_learndash_course_users_search'; $fields[] = $f; } return $fields; }
Changelog
Version | Description |
---|---|
BuddyBoss 1.0.0 | Introduced. |
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.