Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Michael Nielsen 155 posts 812 karma points
    Jun 18, 2014 @ 13:38
    Michael Nielsen
    0

    Members.RegisterMember; No overload for method takes 1 arguments

    Trying to create members in a Partial View, but something isn't right

    With the code below, i get the following error

    CS1501: No overload for method 'RegisterMember' takes 1 arguments

    Reference documentation: http://our.umbraco.org/Documentation/Reference/Querying/MemberShipHelper/ ;

    Umbraco v. 7.1.4

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @using Umbraco.Core;
    @using Umbraco.Core.Models;
    @using Umbraco.Core.Services;
    @{
        var message = "";
    
        if(IsPost){
            if (Members.GetByEmail(Request.Form["customerEmail"]) == null){
    
                var memberModel = Members.CreateRegistrationModel();
    
                memberModel.Name = Request.Form["customerName"];
                memberModel.Email = Request.Form["customerEmail"];
                memberModel.Password = Request.Form["customerPassword"];
    
                Members.RegisterMember(memberModel);
    
            } else {
                    message = "User exists";
            }
        }
    }
    
  • Michael Nielsen 155 posts 812 karma points
    Jun 18, 2014 @ 18:17
    Michael Nielsen
    100

    Solved it with MemberService

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @{
    var message = "";
        var MemberService = ApplicationContext.Current.Services.MemberService;
    
        if(IsPost){
            if (Members.GetByEmail(Request.Form["customerEmail"]) == null){
                var newMember = MemberService.CreateMember(Request.Form["customerUsername"],Request.Form["customerEmail"],Request.Form["customerName"],"MemberType");
    newMember.SetValue("customProperty", Request.Form["customerPropertyValue"]);
    newMember.IsApproved = true; MemberService.Save(newMember); MemberService.SavePassword(newMember,Request.Form["customerPassword"]);
    } else { message = "User exists";
    } } }
  • 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.

Please Sign in or register to post replies