Skip to content

Instantly share code, notes, and snippets.

/**
* Ninja Tables - Current Month Date Range Filter
*
* Automatically applies the current month date range
* to a Ninja Tables custom date range filter on page load.
*
* Date Format: DD/MM/YYYY
*
* Example:
* From Date: 01/06/2026
/*
# Ninja Tables FooTable Pagination at Top
Moves the existing FooTable pagination controls in Ninja Tables / Ninja Tables Pro from the table footer to above the table.
This is intended for Ninja Tables using the default FooTable renderer.
## Usage
1. Add `JS` to the table's Custom JS field.
@annuman97
annuman97 / fluentforms-preserve-plus-email-redirect.php
Created May 20, 2026 05:44
Temporary Fluent Forms workaround to preserve plus-addressed email values in redirect query strings.
<?php
// Temporary Fluent Forms workaround:
// Preserve plus-addressed emails when passing email through redirect query string.
add_filter('fluentform/submission_confirmation', function ($returnData, $form, $confirmation, $insertId = null, $formData = []) {
$sourceFormId = 29; // Form #1 ID
$emailFieldName = 'email'; // Form #1 email field name
$queryKey = 'email'; // Redirect URL query key: ?email=
if ((int) $form->id !== $sourceFormId || empty($returnData['redirectUrl'])) {
@annuman97
annuman97 / fluentcommunity-basic-pwa-snippet.php
Created May 19, 2026 11:51
A basic PWA snippet for FluentCommunity portal that adds a web app manifest, service worker registration, app-like home screen support, and a simple offline fallback. This is a temporary/basic PWA wrapper and does not include FluentCommunity push notification handling.
<?php
if (!function_exists('fcom_snippet_pwa_portal_start_url')) {
add_action('init', function () {
$fcomPwa = isset($_GET['fcom_pwa']) ? sanitize_key($_GET['fcom_pwa']) : '';
if ($fcomPwa === 'manifest') {
fcom_snippet_pwa_serve_manifest();
}
if ($fcomPwa === 'sw') {
@annuman97
annuman97 / ninja-tables-custom-sql-ajax-chunk-fix.php
Created May 8, 2026 11:39
**Gist Name:** `ninja-tables-custom-sql-ajax-chunk-fix.php` **Description:** Fixes Ninja Tables Pro Custom SQL tables loading only the first Ajax chunk by calculating the real SQL row count and setting the missing chunk metadata, scoped only to `raw_sql` Ajax tables.
<?php
add_filter('ninja_table_rendering_table_vars', function ($tableVars, $tableId) {
if (empty($tableVars['provider']) || $tableVars['provider'] !== 'raw_sql') {
return $tableVars;
}
if (empty($tableVars['render_type']) || $tableVars['render_type'] !== 'ajax_table') {
return $tableVars;
}
@annuman97
annuman97 / fluentcommunity-course-toggle-shortcode.php
Last active April 24, 2026 21:13
FluentCommunity Course Toggle (Collapsible Section) – Shortcode Snippet
<?php
/**
* FluentCommunity Course Toggle (Collapsible Section) – Shortcode Snippet
*
* This snippet adds a simple collapsible / toggle (accordion-style) section
* to FluentCommunity course lessons using a shortcode.
*
* ----------------------
* Usage:
@annuman97
annuman97 / leaderboard_name_change.php
Created March 31, 2026 09:52
Show community username instead of full name in Fluent Community leaderboard
<?php
add_filter('fluent_community/leaderboard_api_response', function ($response, $xProfiles, $requestData) {
if (empty($response['leaderboard']) || !is_array($response['leaderboard'])) {
return $response;
}
foreach ($response['leaderboard'] as $groupIndex => $group) {
if (empty($group['items']) || !is_array($group['items'])) {
@annuman97
annuman97 / hide_leaderboard.php
Created March 31, 2026 09:42
Option(on User Profile) to display/hide Leaderboard publicly in Fluent Community
if (!defined('ABSPATH')) {
return;
}
if (!class_exists('FCOM_Leaderboard_Optout_Profile_Field_Snippet')) {
class FCOM_Leaderboard_Optout_Profile_Field_Snippet
{
const FIELD_SLUG = '_hide_from_leaderboard';
const GROUP_SLUG = '_privacy_settings';
@annuman97
annuman97 / messageOnlyToAdmininFCommunity.php
Last active February 2, 2026 09:01
This snippet automatically sends a private welcome message from an admin to every newly registered user in FluentCommunity (using the FluentCommunity Chat add-on). It works around the current limitation where members cannot initiate private messages with admins only. Instead, the admin initiates the conversation at registration time, allowing th…
<?php
/**
* Auto Welcome DM from Admin to New User (FluentCommunity Chat)
*/
defined('ABSPATH') || exit;
add_action('user_register', function ($user_id) {
// ---- CHANGE THESE TWO VALUES ----
@annuman97
annuman97 / MaxSpacesperUser.php
Last active December 29, 2025 05:51
Limit how many FluentCommunity Spaces a user can join. Applies to both Active and Pending memberships
<?php
add_filter('rest_pre_dispatch', function ($result, $server, $request) {
// If another handler already returned something, respect it
if (!empty($result)) {
return $result;
}