getGUID(), QUESTIONS_EXPERT_ROLE, $group->getGUID())) { // remove the expert role remove_entity_relationship($user->getGUID(), QUESTIONS_EXPERT_ROLE, $group->getGUID()); } } /** * When an expert leaves the site, remove the expert role * * @param string $event the 'delete' event * @param string $type for the 'member_of_site' type * @param ElggRelationship $relationship the provided params * * @return void */ function questions_leave_site_handler($event, $type, $relationship) { if (empty($relationship) || !($relationship instanceof ElggRelationship)) { return; } $user = get_user($relationship->guid_one); $site = elgg_get_site_entity($relationship->guid_two); if (empty($user) || empty($site)) { return; } // is the user an expert in this site if (check_entity_relationship($user->getGUID(), QUESTIONS_EXPERT_ROLE, $site->getGUID())) { // remove the expert role remove_entity_relationship($user->getGUID(), QUESTIONS_EXPERT_ROLE, $site->getGUID()); } }