Skip to content

Instantly share code, notes, and snippets.

@MrVibe
Last active December 20, 2020 07:14
Show Gist options
  • Save MrVibe/bd93c3613bbb8f9c666a069c195cafea to your computer and use it in GitHub Desktop.
Save MrVibe/bd93c3613bbb8f9c666a069c195cafea to your computer and use it in GitHub Desktop.
Private replies visible to course members. vibe-helpdesk
add_filter('bbp_reply_is_private',function($return,$reply_id){
$api = Vibe_HelpDesk_API::init();
if(!empty($api->user)){
$forum_id = get_post_meta($reply_id,'_bbp_forum_id',true);
global $wpdb;
$course_id = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key='vibe_forum' AND meta_value = %d",$forum_id));
if(!empty($course_id)){
if(bp_course_is_member($course_id,$api->user->id)){
return false;
}
}
}
return $return;
},10,2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment