Copied to clipboard

Flag this post as spam?

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


  • Daniel Wahlstedt 1 post 21 karma points
    Mar 20, 2015 @ 11:58
    Daniel Wahlstedt
    0

    Do not want to become logged in after register.

    hey! I have just started using Umbraco and so far I love it, but still.. I am abit noobish with it. Well, the problem is that when I have created the Register-macro.. (it works). I do NOT want to become logged in as the user that I have registered.. So if Im logged in as a user "admin" I want that user to be able to create other users without logging in as them.. I would really love some help! :)

     

    thanks

    /Daniel

  • Tobias Klika 101 posts 570 karma points c-trib
    Mar 20, 2015 @ 12:18
    Tobias Klika
    0

    I am not sure what's in the macro, but I know how to do it via regular code.

    For Member registration you use the new (ok, not so new) MembershipHelper. (It's available as @Members in views and as Members in Controllers).

    A member is created by creating an instance of RegisterModel:

    RegisterModel data = Members.CreateRegistrationModel("Member");
    data.Email = model.Email;
    data.LoginOnSuccess = true; // set this to false
    data.Name = model.FirstName + " " + model.LastName;
    ...
    

    This model is passed to the RegisterMember method:

    MembershipCreateStatus status;
    MembershipUser user = Members.RegisterMember(data, out status, true); // set third param to false
    

    The third param here (which is true in my example) is logMemberIn. By setting this to false it doesn't log you in after creating the member. There's also a data.LoginOnSuccess in the first code snippet - better set this to false too, I am not sure why there are two places where you can set it.

    Hope this helps! And if it helps, would be great as you would mark it as an answer :)

Please Sign in or register to post replies

Write your reply to:

Draft