Change addFriend function to allow approval by selected friend
Permalink
I want to change the way the "Add Friend" function works in the "Members/profiles" views. Once you search for a friend's name, you have the choice to add them as a friend.
I would rather it be a request to add a friend where the friend has to approve the request before the friend appears in the requestor's friend list to limit unwanted associations among members.
In the Profile/view/x, the public viewable attributes would be limited until the profiled person is an approved friend.
In the code below "addFriend function in \users_friends.php, $status field value of null is added to the SQL UsersFriends table with every added friend. Can this column be used for "Approval" Status?
I would rather it be a request to add a friend where the friend has to approve the request before the friend appears in the requestor's friend list to limit unwanted associations among members.
In the Profile/view/x, the public viewable attributes would be limited until the profiled person is an approved friend.
In the code below "addFriend function in \users_friends.php, $status field value of null is added to the SQL UsersFriends table with every added friend. Can this column be used for "Approval" Status?
static function addFriend( $friendUID, $uID=0, $status=''){ if( !intval($friendUID) ) return false; if( !intval($uID) ){$u = new User(); if(!$u || !intval($u->uID)) return false; $uID=$u->uID;} $db = Loader::db(); if( UsersFriends::isFriend( $friendUID, $uID ) ){ $vals = array( $status, $friendUID, $uID ); $sql = 'UPDATE UsersFriends SET status=? WHERE friendUID=? AND uID=?'; }else{ $vals = array( $friendUID, $uID, $status, date("Y-m-d H:i:s")); $sql = 'INSERT INTO UsersFriends ( friendUID, uID, status, uDateAdded ) values (?, ?, ?, ?)'; } $db->query($sql,$vals); return true;
Viewing 15 lines of 16 lines. View entire code block.
Hi, did you find out some kind of solution?
Did anybody get anywhere with this?
Or can anyone shed light on the code required to try and achieve the "request / approval" function?
Or can anyone shed light on the code required to try and achieve the "request / approval" function?
My friend request function is not working at all. 'Member Search' window in Profile doesn't give any results at all.
Example is attached.
Please assist.
Example is attached.
Please assist.
It would be useful, if friend request are send via mail and approvals like at fb ;)
I guess the status can be used for that, opinions?