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_rest_controllersFilterAdd REST controllers that extend SpaceBay\Rest\Controller.
spacebay_portal_templateFilterChange the template file used for the portal.
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.
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_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_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.