Skip to content

Instantly share code, notes, and snippets.

@islaytitans
Last active June 30, 2016 16:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save islaytitans/0424e92c29f0f5679ba61c08d09ff2e2 to your computer and use it in GitHub Desktop.
Save islaytitans/0424e92c29f0f5679ba61c08d09ff2e2 to your computer and use it in GitHub Desktop.
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