Empty id in list

You should trim $_POST['user_invitees'] with space character too, because you add space character to $_POST['user_invitees'] in line 270, 276, 280. If you didn't trim space charcter - $userInvitess list of id will contain empty id (space character). Then when you add relationship for this empty id in line 436, this may cause error in Link2:add method (data/Link2.php:483)