Copied to clipboard

Flag this post as spam?

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


  • Andrew 19 posts 39 karma points
    Jun 18, 2012 @ 23:33
    Andrew
    0

    Approving Members

    This may not actually be an API question - my apologees if this is the wrong place for this question.

    I'm trying to simply approve users as they are created. For some reason, IsApproved just refuses to be set to true. Before you say, "You have to call Membership.UpdateUser()" . . . I have already tried that. When I step through the code, IsApproved gets changed to true on the member object when I use mem.IsApproved = true, but then when I call Membership.UpdateUser(mem), it reverts to false. From everything I've read, this SHOULD work, so if you have any idea why it's NOT, I'd appreciate the insight.

    Here's my code:

    protected void btnSubmit_Click(object sender, EventArgs e)
    {
    if (Membership.GetUserNameByEmail(txtEmail.Text) == null)
    {
    MembershipUser mem = Membership.CreateUser(txtUserName.Text, txtPassword.Text, txtEmail.Text);
    mem.IsApproved = true;
    Membership.UpdateUser(mem);
    CreateNewProfile();
    Roles.AddUserToRole(txtUserName.Text, "Customers");
    if (cbxCorporate.Checked)
    {
    Roles.AddUserToRole(txtUserName.Text, "Company");
    }
    }
    Response.Redirect(umbraco.library.NiceUrl(1063));
    }

    And the membership section of my web.config.

    <membership defaultProvider="UmbracoMembershipProvider" userIsOnlineTimeWindow="15">
    <providers>
    <clear />
    <add name="UsersMembershipProvider"
    type="umbraco.providers.UsersMembershipProvider"
    enablePasswordRetrieval="false"
    enablePasswordReset="false"
    requiresQuestionAndAnswer="false"
    passwordFormat="Hashed"
    minRequiredPasswordLength="8"
    minRequiredNonalphanumericCharacters="0"
    umbracoApprovePropertyTypeAlias="approved" />
    <add name="UmbracoMembershipProvider"
    type="umbraco.providers.members.UmbracoMembershipProvider"
    enablePasswordRetrieval="false"
    enablePasswordReset="false"
    requiresQuestionAndAnswer="false"
    passwordFormat="Hashed"
    umbracoApprovePropertyTypeAlias="approved"
    minRequiredPasswordLength="8"
    minRequiredNonalphanumericCharacters="0" />

    </providers>
    </membership>

    Incidentally, I am not sure whether I need both of those providers. They have both always been there, so I didn't mess with it.

    Using Umbraco 4.7.2, Microsoft .NET 4.0, ASP.NET 4.0, and Visual Studio 2010.

  • Andrew 19 posts 39 karma points
    Jun 18, 2012 @ 23:43
    Andrew
    0

    Murphy's law regarding posting in forums:

    1) The answer to your question is always extremely simple, and you will feel sheepish when you figure it out.

    2) You WILL figure it out . . . immediately after you post your question.

    I won't say this is entirely straight-forward, as I don't recall ever reading anything to this effect, but I should've been able to figure it out. The Member Type did not have a property called "approved" to reference by alias.

  • Jahan 20 posts 52 karma points
    Feb 13, 2013 @ 11:24
    Jahan
    0

    Please more describe your answer.

    I have your problem, too.

    My code:

    <membership defaultProvider="UmbracoMembershipProvider" userIsOnlineTimeWindow="15"><providers><clear /><add name="UmbracoMembershipProvider" type="umbraco.providers.members.UmbracoMembershipProvider" enablePasswordRetrieval="false" enablePasswordReset="false" requiresQuestionAndAnswer="false" umbracoApprovePropertyTypeAlias="isApproved" umbracoLockPropertyTypeAlias="isLocked" defaultMemberTypeAlias="WebsiteUsers" passwordFormat="Hashed"/><add name="UsersMembershipProvider" type="umbraco.providers.UsersMembershipProvider" enablePasswordRetrieval="false" enablePasswordReset="false" requiresQuestionAndAnswer="false" passwordFormat="Hashed"/></providers></membership>
    privatevoidEmailConfirmation(String userId){Int32 newUserId =Convert.ToInt32(userId);try{MembershipUser newUser =Membership.GetUser(newUserId);if(newUser !=null){ newUser.IsApproved=true;Membership.UpdateUser(newUser);// when this line of code execute, newUser.IsApproved = false. !!!}}catch(Exception){}}
Please Sign in or register to post replies

Write your reply to:

Draft