How to implement friend system for Wordpress?
Question
At the moment my users posts are only viewable to them. I would like to implement a system where they can choose to share any post with other users they know. The problem I'm having is, how do I make the connection between users?
The best I came up with is to create a table in the db and store their friends by user id's. Example:
user_ID 2 friends_ID 5,9,34,85
user_ID 87 friends_ID 67,2,99,100,58,309
I want to be able to retrieve their friends list so I can use it later in various parts of the site.
I know this will not be simple, but I am fully open to ideas, suggestions or similar plugin. Thank you all in advance.
Solution
BuddyPress can be used as a framework - it allows you to friend other users, and is a good place to start from.
[Update]
This is the structure of the BuddyPress friends table (bp_friends)
CREATE TABLE `wp_bp_friends` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`initiator_user_id` bigint(20) NOT NULL,
`friend_user_id` bigint(20) NOT NULL,
`is_confirmed` tinyint(1) DEFAULT '0',
`is_limited` tinyint(1) DEFAULT '0',
`date_created` datetime NOT NULL,
PRIMARY KEY (`id`),
KEY `initiator_user_id` (`initiator_user_id`),
KEY `friend_user_id` (`friend_user_id`)
);