Global Functions
FluentCRM Core Developer GuideFluentCRM provides global helper functions defined in app/Functions/helpers.php. These are available anywhere after the plugin loads.
FluentCrmApi()
The main entry point for FluentCRM's PHP API. Returns an API class instance for the given key.
$api = FluentCrmApi($key);Available keys:
| Key | Class | Documentation |
|---|---|---|
contacts | FluentCrm\App\Api\Classes\Contacts | Contact API |
companies | FluentCrm\App\Api\Classes\Companies | Company API |
tags | FluentCrm\App\Api\Classes\Tags | Tag API |
lists | FluentCrm\App\Api\Classes\Lists | List API |
extender | FluentCrm\App\Api\Classes\Extender | Extender API |
event_tracker | FluentCrm\App\Api\Classes\Tracker | Event Tracker API |
// Examples
$contact = FluentCrmApi('contacts')->getContact('[email protected]');
$company = FluentCrmApi('companies')->getCompany(15);
FluentCrmApi('event_tracker')->track([
'email' => '[email protected]',
'event_key' => 'page_visited',
'title' => 'Pricing Page Visit',
]);Options
FluentCRM stores its own options in the fc_meta table (not wp_options). These functions mirror WordPress's get_option() / update_option() / delete_option().
fluentcrm_get_option()
$value = fluentcrm_get_option($optionName, $default = '');Parameters
$optionNamestring— Option key$defaultmixed— Value to return if option doesn't exist
Returns mixed
fluentcrm_update_option()
$id = fluentcrm_update_option($optionName, $value);Parameters
$optionNamestring— Option key$valuemixed— Value to store
Returns int — Meta entry ID
fluentcrm_delete_option()
$deleted = fluentcrm_delete_option($optionName);Parameters
$optionNamestring— Option key
Returns bool
Meta CRUD
All meta is stored in the fc_meta table with different object_type discriminators. FluentCRM provides typed helpers for each entity, plus a generic set.
Generic Meta
// Get meta entry — returns Meta model or null
$meta = fluentcrm_get_meta($objectId, $objectType, $key);
// Create or update meta — returns Meta model
$meta = fluentcrm_update_meta($objectId, $objectType, $key, $value);
// Delete meta — if $key is empty, deletes all meta for that object
$deleted = fluentcrm_delete_meta($objectId, $objectType, $key = '');Campaign Meta
// Get — if $returnValue is true, returns the value directly (or false). Otherwise returns Meta model.
$meta = fluentcrm_get_campaign_meta($campaignId, $key, $returnValue = false);
// Create or update — returns Meta model
$meta = fluentcrm_update_campaign_meta($campaignId, $key, $value);
// Delete — if $key is empty, deletes all meta for that campaign
$deleted = fluentcrm_delete_campaign_meta($campaignId, $key = '');Subscriber (Contact) Meta
// Get — returns the unserialized value, or $default
$value = fluentcrm_get_subscriber_meta($subscriberId, $key, $default = '');
// Create or update — returns SubscriberMeta model
$meta = fluentcrm_update_subscriber_meta($subscriberId, $key, $value);
// Delete
$deleted = fluentcrm_delete_subscriber_meta($subscriberId, $key);SMS Campaign Meta
$meta = fluentcrm_get_sms_campaign_meta($campaignId, $key, $returnValue = false);
$meta = fluentcrm_update_sms_campaign_meta($campaignId, $key, $value);
$deleted = fluentcrm_delete_sms_campaign_meta($campaignId, $key = '');Template Meta
$meta = fluentcrm_get_template_meta($templateId, $key);
$meta = fluentcrm_update_template_meta($templateId, $key, $value);
$deleted = fluentcrm_delete_template_meta($templateId, $key);List Meta
$meta = fluentcrm_get_list_meta($listId, $key);
$meta = fluentcrm_update_list_meta($listId, $key, $value);
$deleted = fluentcrm_delete_list_meta($listId, $key);Contact Statuses & Types
fluentcrm_subscriber_statuses()
Get all valid contact subscription statuses.
$statuses = fluentcrm_subscriber_statuses($isOptions = false);Parameters
$isOptionsbool— Iftrue, returns formatted array withid,slug,titlekeys
Returns array
fluentcrm_subscriber_statuses();
// ['subscribed', 'pending', 'unsubscribed', 'transactional', 'bounced', 'complained', 'spammed']
fluentcrm_subscriber_statuses(true);
// [['id' => 'subscribed', 'slug' => 'subscribed', 'title' => 'Subscribed'], ...]Filter: fluent_crm/contact_statuses
fluentcrm_subscriber_editable_statuses()
Same as fluentcrm_subscriber_statuses() but excludes bounced, complained, and spammed.
$statuses = fluentcrm_subscriber_editable_statuses($isOptions = false);Filter: fluent_crm/contact_editable_statuses
fluentcrm_subscriber_sms_statuses()
Get SMS subscription statuses.
$statuses = fluentcrm_subscriber_sms_statuses($isOptions = false);
// ['sms_subscribed', 'sms_pending', 'sms_unsubscribed', 'sms_bounced']fluentcrm_contact_types()
Get contact type definitions.
$types = fluentcrm_contact_types($isOptions = false);
// ['lead' => 'Lead', 'customer' => 'Customer']Filter: fluent_crm/contact_types
fluentcrm_activity_types()
Get contact note/activity type labels.
$types = fluentcrm_activity_types();
// ['note' => 'Note', 'call' => 'Call', 'email' => 'Email', 'meeting' => 'Meeting', ...]Filter: fluent_crm/contact_activity_types
fluentcrm_strict_statues()
Get statuses that block sending (contacts in these statuses won't receive emails).
$statuses = fluentcrm_strict_statues();
// ['unsubscribed', 'bounced', 'complained', 'spammed']fluentCrmEmailSendableStatuses()
Get statuses eligible to receive campaign emails.
$statuses = fluentCrmEmailSendableStatuses();
// ['subscribed', 'transactional']Filter: fluent_crm/email_sendable_statuses
Current Contact
fluentcrm_get_current_contact()
Get the current contact based on logged-in user ID or secure cookie.
$contact = fluentcrm_get_current_contact();
// Returns false|\FluentCrm\App\Models\SubscriberShorthand for FluentCrmApi('contacts')->getCurrentContact(true, true).
Custom Fields
fluentcrm_get_custom_contact_fields()
Get the custom field schema for contacts (cached).
$fields = fluentcrm_get_custom_contact_fields();Returns array — Field definitions from the contact_custom_fields option.
fluentcrm_get_custom_company_fields()
Get the custom field schema for companies (cached).
$fields = fluentcrm_get_custom_company_fields();Returns array — Field definitions from the company_custom_fields option.
Secure Hashes
fluentCrmGetContactSecureHash()
Get or create a long-lived secure hash for a contact. Used for identifying contacts in email links.
$hash = fluentCrmGetContactSecureHash($contactId);
// Returns string hash or falsefluentCrmGetContactManagedHash()
Get or create a managed secure hash that auto-rotates every 30 days.
$hash = fluentCrmGetContactManagedHash($contactId);
// Returns string hashProfile Widget
fluentcrm_get_crm_profile_html()
Get the HTML for a contact's CRM profile widget (photo, name, status, tags, lists, stats).
$html = fluentcrm_get_crm_profile_html($userIdOrEmail, $checkPermission = true, $withCss = true);Parameters
$userIdOrEmailint|string— WordPress user ID or email address$checkPermissionbool— Whether to verify current user has permission to view$withCssbool— Whether to include CSS styles
Returns string — Profile widget HTML, or empty string on failure.
Tracking Settings
fluentcrmTrackClicking()
Check if click tracking is enabled.
$tracking = fluentcrmTrackClicking();
// Returns true, false, or 'anonymous'fluentcrmTrackEmailOpen()
Check if open tracking is enabled.
$tracking = fluentcrmTrackEmailOpen();
// Returns true, false, or 'anonymous'fluentCrmWillTrackIp()
Check if IP address tracking is enabled.
$willTrack = fluentCrmWillTrackIp();
// Returns boolfluentCrmWillAnonymizeIp()
Check if IP addresses should be anonymized per compliance settings.
$anonymize = fluentCrmWillAnonymizeIp();
// Returns boolDatabase Access
fluentCrmDb()
Get a raw database connection instance for direct queries.
$db = fluentCrmDb();
// Returns \FluentCrm\Framework\Database\Query\WPDBConnectionBackground Processing
fluentcrm_queue_on_background()
Fire a non-blocking background HTTP request to process a task asynchronously via admin-ajax.php.
fluentcrm_queue_on_background($callbackName, $payload);Parameters
$callbackNamestring— The callback function name$payloadmixed— Data to pass to the callback
Returns true
Caching
fluentCrmGetFromCache()
Get a value from WP object cache, or compute and store it.
$value = fluentCrmGetFromCache($key, $callback = false, $expire = 600);Parameters
$keystring— Cache key$callbackcallable|false— If cache miss and callable provided, calls it and caches the result$expireint— Cache TTL in seconds (default 600)
fluentCrmSetCache()
Set a value in WP object cache.
fluentCrmSetCache($key, $value, $expire = 600);fluentCrmRunTimeCache()
Static in-memory key-value store. Persists only for the current PHP request.
// Set a value
fluentCrmRunTimeCache('my_key', $value);
// Get a value
$value = fluentCrmRunTimeCache('my_key');fluentCrmPersistentCache()
Database-persisted cache using fc_meta table with persistent_cache object type.
$value = fluentCrmPersistentCache($key, $callback = false, $expire = 600);RTL
fluentcrm_is_rtl()
Check if email templates should render in RTL direction.
$isRtl = fluentcrm_is_rtl();
// Returns boolFilter: fluent_crm/is_rtl
Memory & Timing
fluentCrmIsMemoryExceeded()
Check if PHP memory usage exceeds a given percentage of the limit.
$exceeded = fluentCrmIsMemoryExceeded($percent = 75);
// Returns boolfluentCrmMaxRunTime()
Get the maximum safe execution time in seconds (capped at 55, minus 3 for safety).
$seconds = fluentCrmMaxRunTime();
// Returns intfluentCrmIsTimeOut()
Check if execution time has exceeded the given limit since FLUENT_CRM_STARTING_TIME.
$timedOut = fluentCrmIsTimeOut($maxSeconds = 30);
// Returns boolMenu URLs
fluentcrm_menu_url_base()
Get the admin URL for FluentCRM's classic UI.
$url = fluentcrm_menu_url_base($ext = '');
// e.g., 'admin.php?page=fluentcrm-admin#/'fluent_crm_menu_url_base_new()
Get the admin URL for FluentCRM's v3 UI.
$url = fluent_crm_menu_url_base_new($ext = '');
// e.g., 'admin.php?page=fluent-crm-v3#/'Global Settings
fluentcrmGetGlobalSettings()
Get a value from FluentCRM's global settings (stored in the fluentcrm-global-settings WP option).
$value = fluentcrmGetGlobalSettings($key, $default = false);Gravatar
fluentcrmGravatar()
Get a contact's Gravatar URL, respecting FluentCRM's compliance settings.
$url = fluentcrmGravatar($email, $name = '');Falls back to the default avatar URL when Gravatar is disabled.
Source: app/Functions/helpers.php