Skip to content

Instantly share code, notes, and snippets.

@ahsannayem
Created October 1, 2025 10:40
Show Gist options
  • Save ahsannayem/274e02e696ab5bc85771e5165957da04 to your computer and use it in GitHub Desktop.
Save ahsannayem/274e02e696ab5bc85771e5165957da04 to your computer and use it in GitHub Desktop.
Add tag when Status change from Pending to Subscrived
add_action('fluentcrm_subscriber_status_to_subscribed', function ($subscriber, $oldStatus) {
// Only act when moving from pending to subscribed
if ($oldStatus !== 'pending' || !$subscriber || empty($subscriber->id)) {
return;
}
$tagName = 'Onboarding'; // change as needed
// Ensure the tag exists (FluentCRM model API)
if (class_exists('\FluentCrm\App\Models\Tag')) {
$tag = \FluentCrm\App\Models\Tag::firstOrCreate(
['title' => $tagName],
['slug' => sanitize_title($tagName)]
);
if ($tag && !empty($tag->id)) {
// Attach tag to the subscriber
$subscriber->attachTags([$tag->id]);
}
}
}, 10, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment