Coursepress: I want to allow my students to speak privately with the instructor via Chat plugin

I want to allow my students to speak privately with the instructor via Chat plugin. I am using the plugin Friends and I paste this code on theme functions.php

add_action(‘coursepress_student_enrolled’, ‘link_tutor_student_friend’, 10, 2);

function link_tutor_student_friend($ID, $course_id) {

$instructors = get_post_meta($course_id, ‘instructors’, true);

foreach ($instructors as $instructor) {

if ($instructor != get_current_user_id()) {

friends_add($instructor, get_current_user_id(), 1);

}

}

}

How do I get this to work?