-
-
Save islaytitans/0424e92c29f0f5679ba61c08d09ff2e2 to your computer and use it in GitHub Desktop.
A custom Sitecore pipeline processor for the SuccessAction of the WFFM module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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