What Are Virtual Fields? #
Virtual fields are values that don’t exist as stored user meta but are computed dynamically at sync time. For example, LearnDash course progress percentages are calculated on-the-fly rather than stored in a static meta field.
How They Work #
The plugin uses the ghl_crm_resolve_field_value filter to resolve virtual field values. When a sync operation encounters a mapped field that matches a virtual field pattern, the filter runs and returns the computed value.
Examples #
- LearnDash progress —
ld_progress_percentage_{course_id}resolves to the user’s current completion percentage in that course. - LearnDash status —
ld_progress_status_{course_id}resolves tonot_started,in_progress, orcompleted.
For Developers #
You can register your own virtual fields by hooking into ghl_crm_resolve_field_value:
add_filter('ghl_crm_resolve_field_value', function($value, $field_key, $user_id) {
if ($field_key === 'my_custom_field') {
return calculate_my_value($user_id);
}
return $value;
}, 10, 3);
