diff --git a/tag/locallib.php b/tag/locallib.php index 74c788e77f0..7b7cd460185 100644 --- a/tag/locallib.php +++ b/tag/locallib.php @@ -324,7 +324,7 @@ function tag_print_user_box($user, $return=false) { $usercontext = get_context_instance(CONTEXT_USER, $user->id); $profilelink = ''; - if ( has_capability('moodle/user:viewdetails', $usercontext) || has_coursecontact_role($user->id) ) { + if ($usercontext and (has_capability('moodle/user:viewdetails', $usercontext) || has_coursecontact_role($user->id))) { $profilelink = $CFG->wwwroot .'/user/view.php?id='. $user->id; }