FluentCRM Custom Condition – User Exists
We have a business use case to: check to see if a FluentCRM contact record still has a matching WP user record. We need to go beyond the standard “role check”, and search by email, then if that fails, search by wp user id that is stored in the contact record. Here’s our custom condition code snippet.
add_action('plugins_loaded', function () {
new DVACheckUserExists();
});
/* Purpose: do two specific checks for existence of the USER in wordpress to see if it matches the contact record
(C) DataVaultAlliance Holdings LLC, 2025
Written By: Dan Linstedt
license: for personal use only, not for resale or repackaging UNLESS wpManageNinjas decides to add it to their core engine, in which case we freely give them the code base.
*/
class DVACheckUserExists
{
public function __construct()
{
add_filter('fluentcrm_automation_condition_groups', [$this, 'addAutomationConditions'], 10, 2);
// Correct hook for custom condition evaluation
add_filter('fluentcrm_automation_custom_condition_assert_wp_user_check', [$this, 'assessWpUserExists'], 10, 5);
}
public function addAutomationConditions($groups, $funnel)
{
$customItems = [
[
'label' => __('Contact's WPUser Exists', 'your-textdomain'),
'value' => 'wp_user_check', // must match the hook and handler
'type' => 'single_assert_option',
'options' => [
'true' => 'TRUE',
'false' => 'FALSE'
],
'custom_operators' = ['equals' => 'equals', 'does_not_equal' => 'does not equal'],
'is_multiple' => false,
'is_singular_value' => true,
'is_only_in' => true
]
];
$groups['wp_user_check'] = [
'label' => 'Custom Conditions',
'value' => 'wp_user_check',
'children' => $customItems,
];
return $groups;
}
public function assessWpUserExists($pass, $condition, $subscriber, $sequence, $funnelSubscriberId)
{
$expected = strtolower(trim((string) $condition['data_value'])) === 'true';
$operator = $condition['operator'] ?? 'equals';
// Check for user by email
$wpUser = get_user_by('email', $subscriber->email);
// Fallback using FluentCRM's link
if (!$wpUser && $subscriber->user_id) {
$wpUser = get_user_by('ID', $subscriber->user_id);
}
$userExists = (bool) $wpUser;
if ($operator === 'equals') {
return $userExists === $expected;
} elseif ($operator === 'does_not_equal') {
return $userExists !== $expected;
}
return false;
}
}