# Smart Codes
{{contact.first_name}}) that get replaced with dynamic values when emails are sent. You can register custom SmartCode groups to expose your plugin's data in FluentCRM emails, automation fields, and templates.
## Built-in SmartCode Groups
FluentCRM ships with these SmartCode groups:
| Group | Prefix | Examples |
|-------|--------|----------|
| Contact | `contact` | {{contact.first_name}}, {{contact.email}}, {{contact.phone}} |
| Custom Fields | `contact.custom` | {{contact.custom.company_size}} |
| Company | `contact.company` | {{contact.company.name}}, {{contact.company.industry}} |
| CRM / Business | `crm` | {{crm.business_name}}, {{crm.business_address}} |
| WordPress | `wp` | {{wp.admin_email}} |
| Dynamic Content | `other` | {{other.latest_post.title}}, {{other.date.+2 days}} |
| User Meta | `user.meta` | {{user.meta.billing_phone}} |
### Default Values
Provide a fallback value after a `|` separator:
{{contact.first_name\|\|concat_first\|Hi}} → "Hi John") |
### Combining Default Values and Transformers
{{group.key|default_value||transformer}}
## Registering Custom SmartCodes
Use the Extender API to add your own SmartCode group:
```php
add_action('fluent_crm/after_init', function () {
$key = 'my_plugin';
$title = 'My Plugin Data';
$shortCodes = [
'membership_level' => 'Membership Level',
'points_balance' => 'Points Balance',
'join_date' => 'Join Date',
];
$callback = function ($code, $valueKey, $defaultValue, $subscriber) {
$userId = $subscriber->user_id;
if (!$userId) {
return $defaultValue;
}
switch ($valueKey) {
case 'membership_level':
return get_user_meta($userId, 'membership_level', true) ?: $defaultValue;
case 'points_balance':
return get_user_meta($userId, 'points_balance', true) ?: $defaultValue;
case 'join_date':
$date = get_user_meta($userId, 'join_date', true);
return $date ? date('F j, Y', strtotime($date)) : $defaultValue;
default:
return $defaultValue;
}
};
FluentCrmApi('extender')->addSmartCode($key, $title, $shortCodes, $callback);
});
```
This registers three SmartCodes that can be used in emails:
{{my_plugin.membership_level}}) |
| `$valueKey` | String | The key portion after the dot (e.g., `membership_level`) |
| `$defaultValue` | String | The default value specified by the user (text after `\|`) |
| `$subscriber` | [Subscriber](/database/models/subscriber) | The contact being processed |
**Reserved keys** (cannot be used as `$key`): `crm`, `other`, `contact`, `wp`, `fluentcrm`, `user`, `learndash`, `tutorlms`, `aff_wp`, `edd_customer`, `lifterlms`, `woo_customer`
**Source:** `app/Api/Classes/Extender.php`