guid, "friendrequest", $user->guid) || check_entity_relationship($friend->guid, "friend", $user->guid)) { $user->addFriend($friend->guid); $friend->addFriend($user->guid); remove_entity_relationship($friend->guid, "friendrequest", $user->guid); add_to_river('river/relationship/friend/create', 'friend', $user->guid, $friend->guid); system_message(elgg_echo("friends:add:successful", array($friend->name))); } elseif(add_entity_relationship($user->guid, "friendrequest", $friend->guid)) { system_message(elgg_echo("friendrequest:add:successful", array($friend->name))); } else { register_error(elgg_echo("friendrequest:add:exists", array($friend->name))); } forward(REFERER);