Code Snippets
These snippets are validated against the current core and Pro source trees. Use them in a small custom plugin or an MU plugin rather than editing FluentCommunity directly.
Change the Portal Slug
FluentCommunity\App\Services\Helper::getPortalSlug() checks the saved setting first and then honors the FLUENT_COMMUNITY_PORTAL_SLUG constant.
define('FLUENT_COMMUNITY_PORTAL_SLUG', 'community');To serve the portal from the site root:
define('FLUENT_COMMUNITY_PORTAL_SLUG', '');Resave your WordPress permalinks after changing the slug so the rewrite rules are rebuilt.
Add Custom CSS or JavaScript
The portal template fires fluent_community/portal_head and fluent_community/portal_footer.
add_action('fluent_community/portal_head', function () {
?>
<style>
.fcom_header {
background: #19283a;
}
</style>
<?php
});add_action('fluent_community/portal_footer', function () {
?>
<script>
window.fcomDocsExample = true;
</script>
<?php
});Check Whether a Feature Module Is Enabled
use FluentCommunity\App\Services\Helper;
if (Helper::isFeatureEnabled('course_module')) {
// Course features are enabled.
}Common feature keys seen in the current code and settings payloads include:
course_moduleleader_board_modulegiphy_moduleemoji_modulecloud_storageuser_badge
Add or Remove Space Memberships Programmatically
use FluentCommunity\App\Services\Helper;
$spaceId = 12;
$userId = 34;
Helper::addToSpace($spaceId, $userId, 'member', 'by_admin');
Helper::removeFromSpace($spaceId, $userId, 'by_admin');The built-in helper supports the member, moderator, and admin roles.
Get a User's Space Memberships
use FluentCommunity\App\Services\Helper;
$spaceIds = Helper::getUserSpaceIds($userId);
$spaces = Helper::getUserSpaces($userId);getUserSpaceIds() returns plain IDs. getUserSpaces() returns the loaded space models.
Inspect the Current Portal Base URL
use FluentCommunity\App\Services\Helper;
$portalHome = Helper::baseUrl('/');
$spaceUrl = Helper::baseUrl('/space/general/home');This is safer than concatenating the slug yourself because it respects hash/history routing and any slug override.