Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
add_filter('bp_course_rest_prepare_course',function($response, $course, $request){
$course_id = $request['id'];
$post_thumbnail_id = get_post_thumbnail_id( $course_id );
if(!empty($post_thumbnail_id)){
$image = wp_get_attachment_image_src($post_thumbnail_id,'full');
$image = $image[0];
}
if(!empty($response) && !empty($response->data)){
$response->data['featured_image'] = $image;
}
if(!empty($response) && !empty($response->data) && !empty($response->data)){
$response->data['course']['featured_image'] = $image;
}
return $response;
},10,3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment