I'm working with Umbraco 7.6.5 and using the provided snippet to create the member. Overall, it's working without any issues, but I'm trying to add some custom behavior that I thought would be simple, but are proving to be surprisingly challenging.
When the user completes the form, I want to be able to send a verification e-mail. That in itself is not the issue though. I'm confident I can handle that.
What I want is:
Set the umbracoMemberApproved field to false using the provided registration snippet.
Prevent the account from being automatically logged in when the provided registration snippet is successful.
Am I really not able to use the provided registration snippet and use the CreateMember API instead?
I am also trying to achieve the same thing . Trying to set the default value of member status to False during registration . Have you got the solution ?
Assuming that by "default value of member status to false" you mean setting the IsApproved value to false, then yes!
Here is the bulk of the Razor helper to create the member. Specifically, the IsApproved value is set in the "Create the base member" section.
@helper CreateMember() {
var fullName = HttpUtility.HtmlEncode(HttpContext.Current.Request["fullName"]);
var company = HttpUtility.HtmlEncode(HttpContext.Current.Request["company"]);
var phone = HttpUtility.HtmlEncode(HttpContext.Current.Request["phone"]);
var stateProv = HttpUtility.HtmlEncode(HttpContext.Current.Request["stateProv"]);
var email = HttpUtility.HtmlEncode(HttpContext.Current.Request["email"]);
var pw = HttpUtility.HtmlEncode(HttpContext.Current.Request["pw"]);
IMember checkMember = ApplicationContext.Current.Services.MemberService.GetByEmail(email);
if (checkMember != null) {
Page.Errors.Add("memberExists");
@RenderRegistrationForm();
} else {
try {
@* Create the base member *@
IMember newMember = ApplicationContext.Services.MemberService.CreateMemberWithIdentity(email,email,fullName,"member");
ApplicationContext.Services.MemberService.SavePassword(newMember,pw);
newMember.IsApproved = false;
ApplicationContext.Services.MemberService.Save(newMember);
@* Update the member information with the custom fields *@
var updMember = ApplicationContext.Services.MemberService.GetById(newMember.Id);
updMember.SetValue("company",company);
updMember.SetValue("phone",phone);
updMember.SetValue("stateProv",stateProv);
ApplicationContext.Services.MemberService.Save(updMember);
@* Try to send the validation e-mail *@
@TrySendMail(validationCode);
} catch (Exception ex) {
throw new Exception("Unable to create new member: " + ex.Message);
}
}
}
Setting Member Properties During Registration
Hello All,
I'm working with Umbraco 7.6.5 and using the provided snippet to create the member. Overall, it's working without any issues, but I'm trying to add some custom behavior that I thought would be simple, but are proving to be surprisingly challenging.
When the user completes the form, I want to be able to send a verification e-mail. That in itself is not the issue though. I'm confident I can handle that.
What I want is:
Am I really not able to use the provided registration snippet and use the CreateMember API instead?
Thank you in advance, Rick
Hello Rick,
I am also trying to achieve the same thing . Trying to set the default value of member status to False during registration . Have you got the solution ?
Thanks
Anil,
Assuming that by "default value of member status to false" you mean setting the IsApproved value to false, then yes!
Here is the bulk of the Razor helper to create the member. Specifically, the IsApproved value is set in the "Create the base member" section.
is working on a reply...