Skip to content

Hooks and filters

Hooks marked Pro come from SpaceBay Pro and only fire while it is active.

HookTypeDescription
spacebay_loadedActionAfter every component is loaded.
spacebay_installedActionAfter install or database upgrade on a site.
spacebay_settings_updatedActionAfter settings are saved. Receives new and old settings.
spacebay_settings_schemaFilterAdd your own settings. See Extending SpaceBay.
spacebay_exchange_registerActionSince 1.2.0. Lets an add-on register its own entities for import and export. Receives the registry. See SpaceBay Exchange Format.
spacebay_import_recordFilterSince 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_finishedActionSince 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_emptiedActionSince 1.2.0. In Replace mode, after SpaceBay has emptied its tables. Empty your own tables here. Receives the run ID.
spacebay_import_max_bytesFilterSince 1.2.0. Largest import file in bytes. The default is 2 GB; the lowest value is 1.
spacebay_transfer_retention_daysFilterSince 1.2.0. Days a finished export is kept. The default is 7; the value is held between 1 and 30.
spacebay_import_media_rootsFilterSince 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_columnsFilterSince 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_rowFilterSince 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_controllersFilterAdd REST controllers that extend SpaceBay\Rest\Controller.
spacebay_portal_templateFilterChange the template file used for the portal.
spacebay_portal_routesFilterSince 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_rootFilterSince 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_requestFilterSince 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_clashesFilterSince 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_argsFilterSince 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_markersFilterSince 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_upActionAfter someone created an account on the signup page. Receives the user ID and the checked form values (without the password).
spacebay_two_factor_enabled ProActionAfter a member turned on two-factor authentication. Receives the user ID and the method (app or email).
spacebay_two_factor_disabled ProActionAfter two-factor authentication was removed from an account by the member or an administrator. Receives the user ID.
spacebay_account_emailFilterChange 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_attemptsFilterChange how many login, signup or code attempts are allowed. Receives the limit and the action name.
spacebay_client_ipFilterReturn 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_createdActionAfter a space is created. Receives the space ID and creator ID.
spacebay_space_updatedActionAfter a space is edited. Receives the space ID and changed fields.
spacebay_space_deletedActionAfter a space or group is deleted. Receives the deleted row.
spacebay_membership_changedActionAfter someone joins, asks to join, is approved, invited, blocked or gets a new role.
spacebay_membership_removedActionAfter someone leaves or is removed from a space.
spacebay_space_member_invitedActionAfter a space admin invites or adds someone.
spacebay_member_directory_argsFilterChange the WP_User_Query arguments of the member directory.
spacebay_can_messageFilterWhether one member may message another. Receives the decision, sender ID and recipient ID.
spacebay_message_sentActionAfter a private message is sent. Receives the message, conversation and recipient IDs.
spacebay_conversation_member_leftActionSince 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_delayFilterSeconds a message stays unread before the reminder email (900 by default).
spacebay_message_email_partsFilterChange the unread-messages email (to, subject, message, headers).
spacebay_call_started ProActionAfter a member starts a call. Receives the call and the conversation.
spacebay_call_ice_servers ProFilterChange the STUN/TURN servers sent to browsers, for example to create short-lived TURN credentials per member.
spacebay_member_statsFilterChange the activity totals (posts, comments, likes, spaces) shown on a member’s home page. Receives the totals and the member ID.
spacebay_post_createdActionAfter a post is published. Receives the post and the IDs of mentioned members.
spacebay_post_updatedActionAfter a post is edited.
spacebay_post_deletedActionAfter a post is deleted.
spacebay_comment_createdActionAfter a comment is added. Receives the comment, the post and mentioned member IDs.
spacebay_comment_deletedActionAfter a comment and its replies are deleted. Receives the comment and the IDs of every removed comment.
spacebay_reaction_addedActionAfter a like or save.
spacebay_reaction_removedActionAfter a like or save is removed.
spacebay_points_addedActionAfter 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_awardedActionAfter 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_createdActionAfter an event is added. Receives the event and the space.
spacebay_event_updatedActionAfter an event is changed. Receives the new and the old event.
spacebay_event_deletedActionAfter an event is deleted. Receives the deleted event.
spacebay_event_rsvpActionAfter a member answers an event. Receives the event, the user ID, the new answer (empty when removed) and the previous answer.
spacebay_profile_updatedActionAfter a member saves their profile. Receives the user ID and the saved fields.
spacebay_create_notificationFilterReturn false to skip a notification. Receives the recipient ID, action key and actor ID.
spacebay_notification_createdActionAfter a notification is stored. Receives the notification ID, recipient ID and action key.
spacebay_notification_textFilterText for custom notification actions. Receives the text, action, actor name and stored data.
spacebay_notification_emailFilterChange the recipient, subject, message or headers of a notification email before it is sent.
spacebay_email_preference_defaultsFilterChange which emails new members get by default.
spacebay_blocked_wordsFilterChange the list of blocked words.
spacebay_hold_contentFilterReturn a reason key to hold a post or comment for review, or an empty string to publish it.
spacebay_content_heldActionAfter a post or comment is held for review.
spacebay_content_reportedActionAfter a member reports a post, comment or member.
spacebay_content_approvedActionAfter a moderator approves held content. spacebay_post_created and spacebay_comment_created also fire when new content is approved.
spacebay_content_removedActionBefore a moderator deletes reported or held content.
spacebay_member_pendingActionWhen a new member waits for approval.
spacebay_member_status_changedActionAfter a member is approved, suspended or restored.
spacebay_link_preview_allowedFilterReturn false to stop link previews for a URL.
spacebay_link_preview_resolveFilterReplace 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_viewFilterWhether 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_privateFilterWhether 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_limitFilterChange how many posts, comments or uploads a member may send per minute.
spacebay_leaderboard_cache_secondsFilterHow 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_lengthFilterChange 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_lengthFilterChange 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_lengthFilterChange 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_depthFilterThe 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_bytesFilterThe 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 ProActionAfter SpaceBay Pro has loaded. Receives nothing.
spacebay_shop_requested ProActionAfter a member asks to open a shop. Receives the user ID and the status: pending, or active for community managers.
spacebay_shop_status_changed ProActionAfter 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 ProActionAfter 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 ProActionAfter 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 ProActionAfter 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.

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, and false turns it off. It replaces the saved setting. The filter spacebay_portal_at_root runs after it. When either one is used, the check for clashes before saving is skipped, so check the addresses yourself with wp spacebay portal clashes.
  • Who answers a request. SpaceBay takes its addresses on the parse_request action 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 return false from spacebay_portal_take_request, or hook parse_request after priority 20, or template_redirect before 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 option spacebay_portal_root_rescan asks for a new check, and the transient spacebay_portal_root_checked keeps the 12 hours.
  • Pro routes. SpaceBay Pro adds secure-account to spacebay_portal_routes, and shop only when shops are on and the Shop page option is on.
  • Extension API. The constant SPACEBAY_EXTENSION_API is 5. Since 1.3.0

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.