Kinds of item
Everything members write is an item, and every item has a kind: a post, a reply, a forum topic, a question and its answers, an event, a job, a listing. The components register their kinds the same way your plugin does, on poly_community_register_post_kinds:
function my_plugin_post_kinds( $kinds ) {
$kinds->register( 'recipe', array(
'label' => _x( 'Recipe', 'Post kind', 'my-plugin' ),
'plural' => _x( 'Recipes', 'Post kind', 'my-plugin' ),
'icon' => 'book',
'title' => array( 'mode' => 'required', 'min' => 3, 'max' => 120 ),
'carries' => array( 'pictures' ),
'feeds' => array( 'home', 'all', 'space', 'profile' ),
'replies' => 'comment',
) );
}
add_action( 'poly_community_register_post_kinds', 'my_plugin_post_kinds' );
A kind is kept as a row of its own the first time it is registered, so posts of it keep their kind while the code that registered it is away.
Its arguments
These arguments are stable:
| Argument | Meaning |
|---|---|
label, plural, icon | Its names and its icon. |
title, body | Whether it has a title (none, optional, required, or a rule with mode, min and max) and words. |
carries | The attachments it may carry, or * for all of them. |
fields | Its fields, kept with the profile fields and edited under Settings. |
replies | The kind of its replies, or false for none. |
feeds | The feeds it shows in (home, all, space, profile), read while the Community component runs. An empty list for none. |
written | Where it is written: composer, own (its own form) or elsewhere. |
can | The action its writing needs, which access rules and requirements hold back. |
space_types | The space types it may be posted in. |
grants | Whether it may be shared with chosen members. |
counted | Whether it counts among the posts of its author and its space. |
grants_told | Whether members it is shared with are told. |
votes, lifetime, review, sells, contact, stats, alerts | What a component turns on for it: votes, a life with an end, approval before publishing, paid posting, ways to reach its owner, views, saved searches. |
Writing and reading items
Poly_Community()->items writes and reads items of every kind: create(), get_item(), update(), delete() and data(). The composer reaches them through the REST route poly-community/v1/items, which first asks whether the member may write there. Code that calls create() itself asks Poly_Community()->access first.
Whether someone may see an item is Poly_Community()->access->can_see_item(). Ask it rather than reading an item visibility yourself: spaces, blocks between members, plans and the components all have a say.