1 | <?php |
||
2 | /** |
||
3 | * Elgg add friend action |
||
4 | */ |
||
5 | |||
6 | // Get the GUID of the user to friend |
||
7 | $friend_guid = get_input('friend'); |
||
8 | $friend = get_user($friend_guid); |
||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
9 | |||
10 | if (!$friend instanceof \ElggUser) { |
||
11 | return elgg_error_response(elgg_echo('error:missing_data')); |
||
12 | } |
||
13 | |||
14 | if (!elgg_get_logged_in_user_entity()->addFriend($friend->guid, true)) { |
||
15 | return elgg_error_response(elgg_echo('friends:add:failure', [$friend->getDisplayName()])); |
||
16 | } |
||
17 | |||
18 | return elgg_ok_response('', elgg_echo('friends:add:successful', [$friend->getDisplayName()])); |
||
19 |