Hooks and filters
Hooks marked Pro come from SpaceBay Pro and only fire while it is active.
| Hook | Type | Description |
|---|---|---|
spacebay_loaded | Action | After every component is loaded. |
spacebay_installed | Action | After install or database upgrade on a site. |
spacebay_settings_updated | Action | After settings are saved. Receives new and old settings. |
spacebay_settings_schema | Filter | Add your own settings. See Extending SpaceBay. |
spacebay_exchange_register | Action | Since 1.2.0. Lets an add-on register its own entities for import and export. Receives the registry. See SpaceBay Exchange Format. |
spacebay_import_record | Filter | Since 1.2.0. Change one record before it is imported, or return null to leave it out. Receives the record, the entity name and the run ID. |
spacebay_import_finished | Action | Since 1.2.0. After an import has written everything. Receives the run ID and a summary (counters per entity, started_at, finished_at). |
spacebay_exchange_replace_emptied | Action | Since 1.2.0. In Replace mode, after SpaceBay has emptied its tables. Empty your own tables here. Receives the run ID. |
spacebay_import_max_bytes | Filter | Since 1.2.0. Largest import file in bytes. The default is 2 GB; the lowest value is 1. |
spacebay_transfer_retention_days | Filter | Since 1.2.0. Days a finished export is kept. The default is 7; the value is held between 1 and 30. |
spacebay_import_media_roots | Filter | Since 1.2.0. Folders an import may read picture files from. The default is the uploads folder and the temporary folder; an import from a folder adds that folder while it reads the pictures. A file outside them, or a link that leads out, is refused. Receives the list of absolute folder paths. |
spacebay_members_csv_columns | Filter | Since 1.2.0. Add columns to the members list. A name may use only a to z, 0 to 9 and underscore, up to 64 characters. The fixed columns cannot be removed. |
spacebay_members_csv_row | Filter | Since 1.2.0. Fill your columns in one row. Receives the row, the WP_User and the profile. SpaceBay blanks hidden members’ details and the email column after this filter runs. |
spacebay_rest_controllers | Filter | Add REST controllers that extend SpaceBay\Rest\Controller. |
spacebay_portal_template | Filter | Change the template file used for the portal. |
spacebay_portal_routes | Filter | Since 1.3.0 The first parts of the community addresses that are served at the home address, for example members. Add the pages your add-on registers with the portal router. Names WordPress needs are removed afterwards: wp-*, feed, rss, rss2, atom, rdf, comments, page, embed, trackback, xmlrpc*, sitemap*, robots*, favicon*, .well-known, admin, dashboard, the REST prefix and the category and tag base. A name with * stands for every name that starts with it; the others are removed only when they match exactly. Names are lower-cased first, and a name that is not only a to z, 0 to 9, a dash or an underscore is dropped, and so is a name with a leading, trailing or doubled dash. Receives an array of names. The clash check uses the same list. |
spacebay_portal_at_root | Filter | Since 1.3.0 Whether the community opens at the home address. Receives a boolean: the constant SPACEBAY_PORTAL_AT_ROOT when it is defined, the saved setting otherwise. Forcing the mode in code, with the filter or the constant, skips the check for clashing addresses before saving. |
spacebay_portal_take_request | Filter | Since 1.3.0 Whether SpaceBay answers one request while the community is at the home address. Receives true, the first part of the address (an empty string for the home address) and the WP object. Return false to leave the request to WordPress, for example for an address another plugin must answer. It runs only for requests SpaceBay would take, and the address is still listed as a clash. |
spacebay_portal_root_clashes | Filter | Since 1.3.0 The list of clashes between the community addresses and the rest of the site. Receives rows with address, kind, source, edit_url and detail. Add a row for an address SpaceBay cannot see, or remove one that is harmless. Rows without an address are dropped. The settings check, Site Health, the notice and WP-CLI use this list. |
spacebay_portal_root_query_args | Filter | Since 1.3.0 The query parts that still let the community open at the home address /. Names that start with utm_ are always allowed and are not in the list this filter receives. That list holds fbclid, gclid, msclkid, _gl, mc_cid, mc_eid, ref and redirect_to. Any other part sends the request to WordPress. Receives the list of names. |
spacebay_output_markers | Filter | Since 1.3.0 Whether SpaceBay adds its hidden marks to your pages. Receives true by default. Return false to switch them all off. See Hidden marks. |
spacebay_member_signed_up | Action | After someone created an account on the signup page. Receives the user ID and the checked form values (without the password). |
spacebay_two_factor_enabled Pro | Action | After a member turned on two-factor authentication. Receives the user ID and the method (app or email). |
spacebay_two_factor_disabled Pro | Action | After two-factor authentication was removed from an account by the member or an administrator. Receives the user ID. |
spacebay_account_email | Filter | Change an account email (login code, password reset, welcome) before it is sent. Receives the email parts, the user ID and the parts it was built from. |
spacebay_auth_attempts | Filter | Change how many login, signup or code attempts are allowed. Receives the limit and the action name. |
spacebay_client_ip | Filter | Return the visitor’s real network address when your site is behind a proxy or CDN. Since 1.1.0, Tools → Site Health recommends it when requests seem to come through a proxy and the filter is not used. |
spacebay_space_created | Action | After a space is created. Receives the space ID and creator ID. |
spacebay_space_updated | Action | After a space is edited. Receives the space ID and changed fields. |
spacebay_space_deleted | Action | After a space or group is deleted. Receives the deleted row. |
spacebay_membership_changed | Action | After someone joins, asks to join, is approved, invited, blocked or gets a new role. |
spacebay_membership_removed | Action | After someone leaves or is removed from a space. |
spacebay_space_member_invited | Action | After a space admin invites or adds someone. |
spacebay_member_directory_args | Filter | Change the WP_User_Query arguments of the member directory. |
spacebay_can_message | Filter | Whether one member may message another. Receives the decision, sender ID and recipient ID. |
spacebay_message_sent | Action | After a private message is sent. Receives the message, conversation and recipient IDs. |
spacebay_conversation_member_left | Action | Since 1.1.2. After someone leaves a conversation or is removed from it. Receives the conversation ID, the ID of the member who went and the ID of the member who acted (the same when they left). |
spacebay_message_email_delay | Filter | Seconds a message stays unread before the reminder email (900 by default). |
spacebay_message_email_parts | Filter | Change the unread-messages email (to, subject, message, headers). |
spacebay_call_started Pro | Action | After a member starts a call. Receives the call and the conversation. |
spacebay_call_ice_servers Pro | Filter | Change the STUN/TURN servers sent to browsers, for example to create short-lived TURN credentials per member. |
spacebay_member_stats | Filter | Change the activity totals (posts, comments, likes, spaces) shown on a member’s home page. Receives the totals and the member ID. |
spacebay_post_created | Action | After a post is published. Receives the post and the IDs of mentioned members. |
spacebay_post_updated | Action | After a post is edited. |
spacebay_post_deleted | Action | After a post is deleted. |
spacebay_comment_created | Action | After a comment is added. Receives the comment, the post and mentioned member IDs. |
spacebay_comment_deleted | Action | After a comment and its replies are deleted. Receives the comment and the IDs of every removed comment. |
spacebay_reaction_added | Action | After a like or save. |
spacebay_reaction_removed | Action | After a like or save is removed. |
spacebay_points_added | Action | After points are added or taken away. Receives the user ID, the points, the reason (post, comment, like, daily, event, manual), the total before and the total after. |
spacebay_badge_awarded | Action | After a member gets a badge. Receives the user ID, badge key, the ID of the person who gave it (0 when earned), the row ID and whether a notification is sent. |
spacebay_event_created | Action | After an event is added. Receives the event and the space. |
spacebay_event_updated | Action | After an event is changed. Receives the new and the old event. |
spacebay_event_deleted | Action | After an event is deleted. Receives the deleted event. |
spacebay_event_rsvp | Action | After a member answers an event. Receives the event, the user ID, the new answer (empty when removed) and the previous answer. |
spacebay_profile_updated | Action | After a member saves their profile. Receives the user ID and the saved fields. |
spacebay_create_notification | Filter | Return false to skip a notification. Receives the recipient ID, action key and actor ID. |
spacebay_notification_created | Action | After a notification is stored. Receives the notification ID, recipient ID and action key. |
spacebay_notification_text | Filter | Text for custom notification actions. Receives the text, action, actor name and stored data. |
spacebay_notification_email | Filter | Change the recipient, subject, message or headers of a notification email before it is sent. |
spacebay_email_preference_defaults | Filter | Change which emails new members get by default. |
spacebay_blocked_words | Filter | Change the list of blocked words. |
spacebay_hold_content | Filter | Return a reason key to hold a post or comment for review, or an empty string to publish it. |
spacebay_content_held | Action | After a post or comment is held for review. |
spacebay_content_reported | Action | After a member reports a post, comment or member. |
spacebay_content_approved | Action | After a moderator approves held content. spacebay_post_created and spacebay_comment_created also fire when new content is approved. |
spacebay_content_removed | Action | Before a moderator deletes reported or held content. |
spacebay_member_pending | Action | When a new member waits for approval. |
spacebay_member_status_changed | Action | After a member is approved, suspended or restored. |
spacebay_link_preview_allowed | Filter | Return false to stop link previews for a URL. |
spacebay_link_preview_resolve | Filter | Replace the DNS lookup SpaceBay does before it fetches a link preview, mainly for tests. Receives null and the host name. Return an array of IP addresses to use them, or leave null to ask DNS. Not called when the host is already an IP address. |
spacebay_media_can_view | Filter | Whether a viewer may see a private image. Receives the answer SpaceBay worked out (bool), the media row (array) and the viewer’s user ID (0 for a visitor). Return true or false. |
spacebay_media_is_private | Filter | Whether the images attached to an object are private files, served only to people allowed to read the object. Receives the answer SpaceBay worked out (bool), the object type (for example post or message) and the object ID. Message images are always private. Post images are private unless the space is public and published and the community is not set to members only. |
spacebay_rate_limit | Filter | Change how many posts, comments or uploads a member may send per minute. |
spacebay_leaderboard_cache_seconds | Filter | How long the weekly and monthly leaderboards are kept before they are added up again. Receives the seconds (300) and the period (week or month). Return 0 to add them up on every view. Since 1.0.0. |
spacebay_post_max_length | Filter | Change the longest post allowed, in characters. Receives the Maximum post length setting. The result is kept between 1 and 100,000. Since 1.1.0. |
spacebay_comment_max_length | Filter | Change the longest comment allowed, in characters. Receives the Maximum comment length setting. The result is kept between 1 and 100,000. Since 1.1.0. |
spacebay_message_max_length | Filter | Change the longest chat message allowed, in characters. Starts at 5,000; there is no setting. The result is kept between 1 and 100,000. Since 1.1.0. |
spacebay_comment_max_depth | Filter | The deepest level a reply can nest. A top-level comment is level 1. Receives the limit (5) and returns it; values below 1 are raised to 1. A reply to a comment on the last level is placed next to that comment. Since 1.0.0. |
spacebay_bootstrap_max_bytes | Filter | The largest response, in bytes, that SpaceBay carries inside the portal page so the first screen needs no extra requests. Receives the limit (204800, which is 200 KB). A response over the limit is left out and loaded by a normal request. Since 1.0.0. |
spacebay_pro_loaded Pro | Action | After SpaceBay Pro has loaded. Receives nothing. |
spacebay_shop_requested Pro | Action | After a member asks to open a shop. Receives the user ID and the status: pending, or active for community managers. |
spacebay_shop_status_changed Pro | Action | After an administrator changed the status of a shop. Receives the user ID, the new status, the old status (an empty string when there was no shop) and the administrator’s user ID. |
spacebay_shop_product_saved Pro | Action | After a seller added a product, or edited one so that the product or its status changed. Receives the product row and true for a new product or false for an edit. |
spacebay_shop_product_reviewed Pro | Action | After an administrator approved or rejected a product. Receives the product row after the review, the status before it and the administrator’s user ID. |
spacebay_shop_product_deleted Pro | Action | After a product was deleted. Receives the deleted product row. |
add_action( 'spacebay_settings_updated', function ( $new, $old ) { if ( $new['portal_slug'] !== $old['portal_slug'] ) { // The community moved to a new address. }}, 10, 2 );For hooks that add features to the portal and admin screens, see Extending SpaceBay.
Community home location
Section titled “Community home location”Since 1.3.0 For what the setting does and how clashes are reported, see Community home location. The points below are for developers and site builders.
- wp-config.php.
define( 'SPACEBAY_PORTAL_AT_ROOT', true );turns At the home address on, andfalseturns it off. It replaces the saved setting. The filterspacebay_portal_at_rootruns after it. When either one is used, the check for clashes before saving is skipped, so check the addresses yourself withwp spacebay portal clashes. - Who answers a request. SpaceBay takes its addresses on the
parse_requestaction at priority 20, for GET and HEAD requests. For the home address it steps aside when WordPress or a plugin has already set query vars for the request, or when the query string has a name outside the allowed list. A plugin that must win on one address can returnfalsefromspacebay_portal_take_request, or hookparse_requestafter priority 20, ortemplate_redirectbefore priority 5. The filter does not hide the clash: the address is still listed. - Stored values. The last check is in the option
spacebay_portal_root_clashes. The optionspacebay_portal_root_rescanasks for a new check, and the transientspacebay_portal_root_checkedkeeps the 12 hours. - Pro routes. SpaceBay Pro adds
secure-accounttospacebay_portal_routes, andshoponly when shops are on and the Shop page option is on. - Extension API. The constant
SPACEBAY_EXTENSION_APIis5. Since 1.3.0
Hidden marks
Section titled “Hidden marks”Since 1.3.0 SpaceBay adds a few hidden marks to your pages. For what they are, see What SpaceBay adds to your pages. To switch all of them off, return false from spacebay_output_markers:
add_filter( 'spacebay_output_markers', '__return_false' );Put it in your theme’s functions.php or in a small plugin.