# Global Functions
Fluent Forms provides a set of global functions located in the boot/globals.php file. These functions are available throughout the plugin and can be used in your custom code, themes, or plugins.
- Global Functions
- wpFluentForm($key = null): mixed
- wpFluent(): Builder
- fluentFormApi($module = 'forms'): Form|Submission
- fluentFormRender($atts): string
- fluentFormSanitizer($input, $attribute, $fields): mixed
- fluentFormIsHandlingSubmission(): bool
- fluentFormHandleScheduledTasks(): void
- fluentFormHandleScheduledEmailReport(): void
- fluentFormEditorShortCodes(): array
- fluentFormGetAllEditorShortCodes($form): array
- getFluentFormCountryList(): array
- fluentFormMix($path): string
- fluentformsanitizehtml($html): string
- fluentformbackendsanitizer($inputs, $sanitizeMap): array
- fluentformCanUnfilteredHTML(): bool
- fluentValidator($data, $rules, $messages): Validator
# wpFluentForm($key = null): mixed
Get the Fluent Forms application instance or a specific core module.
Parameters
$keystring|nullModule name (e.g.,'db','request','path.app')
Return mixed — Application instance or the requested module
Usage
// Get the app instance
$app = wpFluentForm();
// Get the database module
$db = wpFluentForm('db');
// Get the request module
$request = wpFluentForm('request');
2
3
4
5
6
7
8
# wpFluent(): Builder
Get the Fluent Forms database query builder instance for direct database queries.
Return \FluentForm\Framework\Database\Query\Builder
Usage
// Query the submissions table
$submissions = wpFluent()->table('fluentform_submissions')
->where('form_id', 5)
->get();
2
3
4
# fluentFormApi($module = 'forms'): Form|Submission
Get the Fluent Forms PHP API for forms or submissions. This is the recommended way to interact with Fluent Forms data programmatically.
Parameters
$modulestringModule name —'forms'or'submissions'
Return \FluentForm\App\Api\Form or \FluentForm\App\Api\Submission
Usage
// Get the Forms API
$formsApi = fluentFormApi('forms');
$form = $formsApi->find($formId);
// Get the Submissions API
$submissionsApi = fluentFormApi('submissions');
2
3
4
5
6
# fluentFormRender($atts): string
Render a Fluent Form programmatically (equivalent to the [fluentform] shortcode).
Parameters
$attsarrayShortcode attributes:idintForm ID (required)titlestring|nullForm title overridecss_classesstringAdditional CSS classespermissionstringRequired user capabilitytypestringForm type —'classic'(default) or'conversational'permission_messagestringMessage shown when user lacks permission
Return string — Rendered form HTML
Usage
// Render form #5 in a template
echo fluentFormRender(['id' => 5]);
// With custom CSS class and permission check
echo fluentFormRender([
'id' => 5,
'css_classes' => 'my-custom-form',
'permission' => 'read',
]);
2
3
4
5
6
7
8
9
# fluentFormSanitizer($input, $attribute, $fields): mixed
Recursively sanitize form input values based on field type. Used internally during submission processing.
Parameters
$inputmixedThe input value to sanitize$attributestring|nullThe field attribute name$fieldsarrayForm field definitions
Return mixed — Sanitized input
Usage
$cleanValue = fluentFormSanitizer($userInput, 'email', $formFields);
# fluentFormIsHandlingSubmission(): bool
Check if the current request is a Fluent Forms submission or async request.
Return bool
Usage
if (fluentFormIsHandlingSubmission()) {
// Current request is a form submission
}
2
3
# fluentFormHandleScheduledTasks(): void
Process failed scheduled actions (retry up to 4 times). Called by WordPress cron.
Usage
// Manually trigger scheduled task processing
fluentFormHandleScheduledTasks();
2
# fluentFormHandleScheduledEmailReport(): void
Process scheduled email reports. Called by WordPress cron.
# fluentFormEditorShortCodes(): array
Get the list of available editor shortcodes for form notifications and confirmations.
Return array — Array of shortcode groups
# fluentFormGetAllEditorShortCodes($form): array
Get all editor shortcodes available for a specific form, including form-specific field shortcodes.
Parameters
$formobjectThe form object
Return array — Array of all available shortcodes
# getFluentFormCountryList(): array
Get the full list of countries with their codes.
Return array — Associative array of country code => country name
# fluentFormMix($path): string
Generate a URL for static assets within the Fluent Forms plugin.
Parameters
$pathstringRelative path to the asset
Return string — Full URL to the asset
# fluentform_sanitize_html($html): string
Sanitize HTML content while preserving allowed tags (including iframes, SVGs, and custom elements). Removes event handlers and JavaScript protocols.
Parameters
$htmlstringHTML content to sanitize
Return string — Sanitized HTML
Usage
$safeHtml = fluentform_sanitize_html($rawHtml);
# fluentform_backend_sanitizer($inputs, $sanitizeMap): array
Sanitize backend inputs recursively using a map of sanitization callbacks.
Parameters
$inputsarrayInput data to sanitize$sanitizeMaparrayAssociative array ofkey => callbackpairs
Return array — Sanitized input data
Usage
$clean = fluentform_backend_sanitizer($data, [
'title' => 'sanitize_text_field',
'email' => 'sanitize_email',
'content' => 'wp_kses_post',
]);
2
3
4
5
# fluentformCanUnfilteredHTML(): bool
Check if the current user can use unfiltered HTML or if field sanitization is disabled.
Return bool
# fluentValidator($data, $rules, $messages): Validator
Create a validation instance for data validation.
Parameters
$dataarrayData to validate$rulesarrayValidation rules$messagesarrayCustom error messages
Return Validator
Usage
$validator = fluentValidator($data, [
'email' => 'required|email',
'name' => 'required|string',
]);
if ($validator->validate()->fails()) {
$errors = $validator->errors();
}
2
3
4
5
6
7
8