A custom Sitecore pipeline processor for the SuccessAction of the WFFM module
public class SuccessGatedContentRedirect : ClientPipelineArgs | |
{ | |
private List<string> _gatedContentSaveActionIds = new List<string>(); | |
public void Process(SubmitSuccessArgs args) | |
{ | |
Assert.IsNotNull((object)args, "args"); | |
if (args.Form != null && !args.Form.SuccessRedirect && FormHasGrantGatedAccessSaveAction(args))) | |
{ | |
string urlString = HttpContext.Current.Request.Url.AbsoluteUri; | |
WebUtil.Redirect(urlString, true); | |
} | |
} | |
private bool FormHasGrantGatedAccessSaveAction(SubmitSuccessArgs args) | |
{ | |
bool isGatedForm = false; | |
foreach (string gatedContentSaveActionId in _gatedContentSaveActionIds) | |
{ | |
isGatedForm = args.Form.SaveActions.ToLower().Trim().Contains(gatedContentSaveActionId.Trim().ToLower()); | |
if (isGatedForm) | |
break; | |
} | |
return isGatedForm; | |
} | |
public void AddGatedContentSaveActionIds(XmlNode configNode) | |
{ | |
Assert.ArgumentNotNull(configNode, "configNode"); | |
string attributeValue = XmlUtil.GetAttribute("value", configNode); | |
_gatedContentSaveActionIds.Add(attributeValue); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment