I have added a custom email field to the member type. I am validating the member email with the custom email field for login. So I need to show a validation message in the Umbraco backend for already existing email while creating a new Umbraco member.
I am trying with the code below but it is not working as expected
private void MemberSaving(IMemberService sender, Umbraco.Core.Events.SaveEventArgs<IMember> e)
{
Random randomNumber = new Random();
var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
foreach (var memberItem in e.SavedEntities)
{
if (memberItem.ContentType.Alias == "Member")
{
var Email = memberItem.Email;
var AdditionalEmail = memberItem.GetValue<string>("additionalEmail");
var IsExist = _memberService.GetByEmail(AdditionalEmail);
if ((string.IsNullOrWhiteSpace(Email.ToLower()) == string.IsNullOrWhiteSpace(AdditionalEmail.ToLower())) || IsExist!=null)
{
e.Cancel = true;
e.Messages.Add(new EventMessage("Invalid email", "You can not add already existing email...", EventMessageType.Success));
}
}
}
}
Show custom validation message in umbraco backed
Hi All,
I have added a custom email field to the member type. I am validating the member email with the custom email field for login. So I need to show a validation message in the Umbraco backend for already existing email while creating a new Umbraco member.
I am trying with the code below but it is not working as expected
Please help to find a solution for this
Thank You
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.