Skip to main content

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:

ArgumentMeaning
label, plural, iconIts names and its icon.
title, bodyWhether it has a title (none, optional, required, or a rule with mode, min and max) and words.
carriesThe attachments it may carry, or * for all of them.
fieldsIts fields, kept with the profile fields and edited under Settings.
repliesThe kind of its replies, or false for none.
feedsThe feeds it shows in (home, all, space, profile), read while the Community component runs. An empty list for none.
writtenWhere it is written: composer, own (its own form) or elsewhere.
canThe action its writing needs, which access rules and requirements hold back.
space_typesThe space types it may be posted in.
grantsWhether it may be shared with chosen members.
countedWhether it counts among the posts of its author and its space.
grants_toldWhether members it is shared with are told.
votes, lifetime, review, sells, contact, stats, alertsWhat 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.