Posts 2 Users
scribu edited this page Jan 17, 2012
·
8 revisions
With this plugin, it's also possible to create many-to-many relationships between posts and users.
Here's how you would define such a connection type:
p2p_register_connection_type( array(
'name' => 'multiple_authors',
'from' => 'article',
'to' => 'user',
'to_query_vars' => array( 'role' => 'editor' )
) );
You can leave out the 'to_query_vars' => array( 'role' => 'editor' )
line, in which case all users can be connected.
To get a list of users connected to a certain post, you can write:
$users = get_users( array(
'connected_type' => 'multiple_authors',
'connected_items' => $post_id
) );