PHP
Everything here is a method of wordplus_streams(), there once Live Stream has loaded. Check with function_exists( 'wordplus_streams' ) (Overview).
$streams = wordplus_streams();
$id = $streams->create( array( 'title' => 'Weekly class' ) );
echo $streams->render( $id );
Streams
create()
wordplus_streams()->create( array $args ): int|WP_Error
Makes a stream and answers its ID.
| Argument | |
|---|---|
title | Its title, plain text, up to 120 characters. Required. |
settings | The settings to change from those of a new stream. |
object_type | What it is made for: a kind of thing of your plugin, in lower case letters, digits, _ and -, up to 64 characters. Prefix it with the name of your plugin, as my_course. |
object_id | And the ID of that thing, a positive number. |
host | The user it is the stream of, a member going live: they host it, as administrators do, and go live where you put its studio. |
$stream_id = wordplus_streams()->create( array(
'title' => $group->name,
'object_type' => 'my_group',
'object_id' => $group->id,
'settings' => array(
'access' => 'logged_in',
'chat_with' => 'light',
'scheduled' => strtotime( '2026-11-02 18:00:00' ),
),
) );
if ( is_wp_error( $stream_id ) ) {
// wordplus_stream_no_title, or wordplus_stream_object for a wrong object_type or object_id.
}
wordplus_stream_created runs once it is made.
update()
wordplus_streams()->update( int $id, array $args ): true|WP_Error
Changes the title, the settings given, what the stream is made for and its host. The settings not given stay as they are. Give an empty object_type and object_id to make it a stream of its own again, and host 0 for a stream of no one. Errors: wordplus_stream_not_found, wordplus_stream_no_title, wordplus_stream_object, wordplus_stream_host.
wordplus_streams()->update( $stream_id, array( 'settings' => array( 'reactions' => false ) ) );
Turning reactions off or on tells everyone watching at once, during a stream too. wordplus_stream_updated runs after.
delete()
wordplus_streams()->delete( int $id ): bool
Deletes a stream for good. Pages, blocks and shortcodes that showed it show nothing. Answers whether it was deleted. wordplus_stream_deleted runs after.
get()
wordplus_streams()->get( int $id ): ?array
A stream, or null when there is none with that ID:
| Key | |
|---|---|
id | Its ID on the site. |
stream | Its ID on the cloud, s12, which JavaScript names it by too. |
title | Its title. |
settings | Its settings, all of them. |
object_type, object_id | What it was made for, '' and 0 for nothing. |
host | The user it is the stream of, 0 for no one. |
page | Where viewers watch it, which the Live now list links to and the player shares: the page chosen in its settings, the first public page found showing it, or what wordplus_stream_page_url says. '' while there is none. |
shortcode | Its shortcode, [wordplus_stream id="12"]. |
created | When it was made, a timestamp. |
get_object()
wordplus_streams()->get_object( int $id ): ?array
What a stream was made for, array( 'type' => 'my_group', 'id' => 5 ), without the rest of it. null for a stream made for nothing, or no stream. Quick enough for hooks, which are asked often.
get_host()
wordplus_streams()->get_host( int $id ): int
The user a stream is the stream of, 0 for no one or no stream. Quick enough for hooks, and the one to read in wordplus_stream_page_url, which wordplus_streams()->get() asks.
get_object_stream()
wordplus_streams()->get_object_stream( string $object_type, int $object_id ): ?array
The stream made for a thing of yours, as wordplus_streams()->get() gives it, the newest when there are more. null for none.
get_streams()
wordplus_streams()->get_streams( array $args = array() ): array
Streams, the newest first, each as wordplus_streams()->get() gives it.
| Argument | |
|---|---|
object_type | Only those made for things of this kind. |
object_id | With object_type, only those made for this thing. |
host | Only the streams of this user. |
search | Words in the title. |
number | How many, up to 100. 20 when not given. |
page | Which page of them, from 1. |
Settings
The settings of a stream, as its page in Live Stream → Studio → Streams has them.
| Setting | A new stream | |
|---|---|---|
access | Who watches: public (everyone), logged_in, or roles (those in watch_roles). | public |
watch_roles | The roles that watch, for roles. | None |
chat | Whether it has chat. | true |
chat_with | light, the chat of WordPlus Cloud, never saved, or better_messages, a Better Messages chat room made for it (Chat). | better_messages where Better Messages can show a room, otherwise light |
guest_chat | Whether visitors who are not logged in write in the light chat. | false |
chat_offline | Whether the light chat is open while the stream is not live. Its moderators always write. | false |
chat_links | Whether everyone may post links, or only moderators. | true |
chat_fresh | Whether the light chat starts empty each time the stream goes live. | false |
people | Who sees who is here: mods or all. | mods |
mod_roles | Roles that moderate it, besides its hosts and those who moderate the comments of the site. | None |
reactions | Whether viewers send reactions over the picture. | true |
autostart | Whether it goes live as OBS connects with its token, with nobody in the studio, and again when OBS comes back after a break (From OBS). | false |
sessions | When it is planned to go live: a list of times, each at (a timestamp) and its own title ('' for the title of the stream), the soonest first, at most 100. A time is the next one until 12 hours after its start, and gone after (A schedule). Sent, it replaces the times planned. at may also be a date and time in the time zone of the site, 2026-10-26T08:15, and a time may be its timestamp alone. | None |
scheduled | The start of the next time planned, a timestamp. 0 for none. Sent without sessions, it moves the next time, and 0 removes it. | 0 |
cover | The image before it starts, a URL. '' for the cover of the site. | '' |
page | The post the Live now list links to. 0 for the first public page found showing it. | 0 |
texts | Words of its own in place of those of the player: soon, soon_note, waiting, full, ended, thanks, chat_before, chat_after. | None |
room_locked | In its Better Messages chat room, whether it stays on screen while live. | false |
A setting with a value it cannot take keeps the one it had.
A Better Messages chat room is made for a stream when it is saved by an administrator, through Better Messages. A stream your code makes while someone else is logged in has the light chat until then. Set chat_with to light when your plugin has a chat of its own to show beside it, or none.
On your screens
render()
wordplus_streams()->render( int $id, array $args = array() ): string
A stream, or a part of it, as HTML for the page being made, with its script and styles. '' when there is no such stream.
echo wordplus_streams()->render( $stream_id ); // In one piece.
echo wordplus_streams()->render( $stream_id, array( 'layout' => 'side' ) ); // The player with the chat beside it.
echo wordplus_streams()->render( $stream_id, array( 'part' => 'player', 'shape' => '9:16' ) );
part | What it shows | Its choices |
|---|---|---|
all | The stream in one piece: the player, and the chat beside it where there is room. Its hosts get the way to their studio over it, or the studio itself where they have none to go to. | layout: side, below, player or vertical for a ready layout of the parts below. |
player | The picture and its controls, the countdown before the start and the screen after the end. | shape: 16:9, 4:3 or 9:16, otherwise the shape of the picture. sticky: keeps it at the top of the screen of a phone while live. clock and names: shown or hidden. |
chat | The chat, with its moderation. | height: 240 to 1200 pixels. |
studio | Going live from the page, for the hosts of the stream. Everyone else sees nothing. | None. |
details | The title, when it started, how many watch, reactions and sharing. | title, meta, actions: each false to leave it out. |
Each one is the block and the shortcode of the same part (Putting a stream on a page). The parts of one stream on a page share one connection.
config()
wordplus_streams()->config( int $id, array $args = array() ): ?array
What wordplusStreams.mount() takes in the browser to show a stream or a part of it for the current user (JavaScript). It takes part and its choices, as wordplus_streams()->render(), and url, the address of the page it is shown on, to share and to come back to after logging in. null when there is no such stream, or when the site has no WordPlus Cloud key yet and the current user is not one of the hosts of the stream. Its hosts get it there too, to set up their camera and watch a test stream that only they can see.
enqueue()
wordplus_streams()->enqueue(): bool
Puts the player on the page for a script of yours that shows streams itself: its handle is wordplus-streams, which your script depends on. wordplus_streams()->render() needs none of this.
enqueue_live()
wordplus_streams()->enqueue_live(): bool
Puts wordplusStreams.live on the page, which tells your script the streams live now and again each time that changes (JavaScript): its handle is wordplus-streams-live. Answers false on a site whose licence does not include live streaming.
Who may do what
user_can()
wordplus_streams()->user_can( int $id, string $action, ?int $user_id = null ): bool
Whether a user may watch, host, moderate or chat (write in the light chat) in a stream, as its settings and your hooks decide. 0 for a visitor, the current user when not given.
if ( wordplus_streams()->user_can( $stream_id, 'host' ) ) {
echo wordplus_streams()->render( $stream_id, array( 'part' => 'studio' ) );
}
studio_url()
wordplus_streams()->studio_url( int $id, ?int $user_id = null ): string
Where a host goes live in a stream: Live Stream → Studio for administrators, or what wordplus_stream_studio_url says. '' for a user who does not host it, or has nowhere to go.
What is live
live_streams()
wordplus_streams()->live_streams(): array|WP_Error
The streams live now, the latest first, by their IDs:
array(
12 => array( 'id' => 12, 'stream' => 's12', 'started' => 1793638800, 'viewers' => 31 ),
)
It asks WordPlus Cloud, at most once every 15 seconds, and keeps the answer for the requests between. A page a cache keeps shows what was live when it was cached: wordplusStreams.live tells the page itself as it changes. An error when the licence of the site does not include live streaming (wordplus_stream_not_licensed), or the cloud did not answer (wordplus_stream_no_answer).
is_live()
wordplus_streams()->is_live( int $id ): bool
Whether a stream is live now, as wordplus_streams()->live_streams() tells. false too when the cloud did not answer.
can_stream()
wordplus_streams()->can_stream(): bool
Whether the site can stream: it has its licence, and the licence includes live streaming.