[wp-hackers] Post Sharing/Privacy

Ryan Boren ryan at boren.nu
Tue Dec 13 04:11:22 GMT 2005


As an example of how the Role/Cap system can be used to restrict who can
view a post, I created the attached test plugin.

Basically, you can define a relationship between yourself and another
user and then tag your posts as being viewable by friends, family, or
anyone.  A post tagged for "Friends" is viewable by those you have
designated as friends.

Relationships are saved in the usermeta table under a 'relationships'
key.  Relationships can be XFN keywords or any old string.

Those relationships that are allowed to view a particular post are
stored in a _share_with key in the postmeta table.

When deciding if the current user can view a post, we retrieve the
post's '_share_with' and the post author's 'relationships'.  If any of
the keywords in '_share_with' are present in the 'relationships' between
the post author and the current user, the current user can view the
post.

There is currently no UI for manipulating _share_with and relationships.
This plugin is just a developer's demo.  Feel free to take it and make
it useful.  There are some comments in the plugin concerning how it
could be built out further.

Ryan




-------------- next part --------------
A non-text attachment was scrubbed...
Name: post_sharing.php
Type: application/x-php
Size: 2533 bytes
Desc: not available
Url : http://comox.textdrive.com/pipermail/wp-hackers/attachments/20051213/23cd7803/post_sharing.bin


More information about the wp-hackers mailing list