Skip to content

Instantly share code, notes, and snippets.

View BenGGolden's full-sized avatar

Ben Golden BenGGolden

View GitHub Profile
public class SetPasswordSaveAction : UserBaseAction
{
private ID _formId;
public override void Execute(ID formId, AdaptedResultList adaptedFields, ActionCallContext actionCallContext = null,
params object[] data)
{
_formId = formId;
var password = adaptedFields.GetEntry(PasswordField, "Password")?.Value ?? string.Empty;
var userName = Tracker.Current?.Session.Contact.Identifiers.Identifier;
var user = Membership.GetUser(userName);
@BenGGolden
BenGGolden / IsInEngagementStateCondition.cs
Created November 29, 2016 15:37
Sitecore rule engine condition to determine if the current user is in a particular engagement plan state
public class IsInEngagementStateCondition<T> : WhenCondition<T> where T : RuleContext
{
public ID StateId { get; set; }
protected override bool Execute(T ruleContext)
{
var automationStateManager = Tracker.Current.Session.CreateAutomationStateManager();
return automationStateManager.IsInEngagementState(StateId);
}
}
@BenGGolden
BenGGolden / RegisterGoalAction.cs
Created November 27, 2016 19:29
Sitecore rule engine action to register a goal
public class RegisterGoalAction<T> : RuleAction<T> where T : RuleContext
{
public ID GoalId { get; set; }
public override void Apply(T ruleContext)
{
if (!Tracker.IsActive || Tracker.Current.CurrentPage == null) return;
var goal = (PageEventItem)Context.Database.GetItem(GoalId);
if (goal != null)
{