You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Creating a segment can be done as with any element. The challenge is going to be to construct the contact condition, which can be passed in using a ContactCondition class or an array. The simplest way to figure this out might be go inspect the request parameters in the Network tab of your browser’s dev tools when creating/saving a segment in the CP.
useCraft;
use putyourlightson\campaign\elements\SegmentElement;
$segment = newSegmentElement();
$segment->title = 'Test Segment';
$segment->slug = 'test-segment';
$segment->segmentType = 'regular';
// Pass in a ContactCondition class or an array$segment->setContactCondition([]);
Craft::$app->getElements()->saveElement($segment);
bencroker
changed the title
Ading segment
Adding a segment programatically
Sep 1, 2024
Support Request
Is there a way to add segments programmatically?
As for contacts we have:
FormService::createAndSubscribe()
Is there a method for segments to be added from a module?
Thanks for your help.
Plugin Version
2.15.3
The text was updated successfully, but these errors were encountered: