Copied to clipboard

Flag this post as spam?

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


  • Eric 35 posts 55 karma points
    Feb 08, 2010 @ 12:30
    Eric
    0

    adding a Member to a MemberGroup doesn't reflect in back-end

    Hello there,

    I'm using

    MemberGroup mg = MemberGroup.GetByName("namedGroup");
    m
    .AddGroup(mg.Id);

    to add programmaticaly a member "m" to a MemberGroup.

    It works (the "namedGroup" id is correctly inserted into the DB in table Member2MemberGroup) but when I access the Members in Umbraco back-end and click the member "m", it seems like he does not belong to my "namedGroup" ("namedGroup" is on the left part and doesn't display on the right part unless I move it and save member. Any idea of what is causing this ?

    Thanks a lot.

    Eric

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Feb 08, 2010 @ 12:48
    Lee Kelleher
    0

    Hi Eric,

    That is strange! To my knowledge, if the member Id and memberGroup Id are inserted into the Member2MemberGroup table, then the mapping should be done.  Could your browser be caching the member's details? (Test in a different browser, just in case).

    I've used similar code before and it worked fine.  Let me know how it goes.

    Cheers, Lee.

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Feb 08, 2010 @ 12:49
    Dirk De Grave
    0

    Eric,

    Can't comment on the issue, you could be right about that, but if you're using v4, you should be using the standard asp.net membership functions as found on the wiki instead of the member/membergroup functions.

     

    Cheers,

    /dirk

     

  • Richard Soeteman 4046 posts 12899 karma points MVP 2x
    Feb 08, 2010 @ 13:52
    Richard Soeteman
    0

    Hi Eric,

    I agree with Dirk that it is better to use the default asp.net Membership methods. However in my Import tool I want to directly  talk to the member objects.  I use  member.AddGroup(groupId); to assign groups to a Member (whichs works). And I use member.Save(); (don't think that;s even needed)

    Hope it helps you.

    Richard

  • Eric 35 posts 55 karma points
    Feb 08, 2010 @ 14:08
    Eric
    0

    To Lee: This is not a browser cache problem (checked) but I thing I found something.

    This occurs on a Umbraco V4 updated from V3. Before update, it worked great.

    This is about a newsletter. When people wants to subscribe, a new Member is created according to the e-mail they provide. Because double opt-in is required by law, a mail is sent to the mail address asking people to confirm that they are really interested in receiving mail from us. When they click on the confirm link, this "Member" become an "active subscriber" .

    I have noticed that it still works with old registered address (I can set it manually in the active subscriber group) but not with the newest.

    Having a look on the DB, I guess this occurs because I create new Members without  Login and Password. Is this possible ?

    To Dirk: I will probably upgrade my code but as I mentioned here this happens on an updated Umbraco (from v3 to v4).

  • Eric 35 posts 55 karma points
    Feb 08, 2010 @ 14:27
    Eric
    0

    Hey Lee, 

    Testing on IE8 and Safari, the field "Login" is blank (as it should) but in FF it is set to admin !!!

    Weird.

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Feb 08, 2010 @ 14:35
    Lee Kelleher
    0

    Hmmm... that could be a setting in Firefox, can't remember the exact name - something like "auto populate fields"?

    Still doesn't get us any close to solving your problem though... hmmm.

    Are you using "namedGroup" literally, or is it being set elsewhere?  Double-check that it's being set correctly?

    You might want to set the Member's login to something too? Maybe to their email address? or a sanitised version of their name? (without spaces and lowercase?)

    Cheers, Lee.

  • Petr Snobelt 923 posts 1535 karma points
    Feb 08, 2010 @ 16:02
  • Eric 35 posts 55 karma points
    Feb 08, 2010 @ 18:26
    Eric
    1

    @Lee: Thanks for your help. The issue with Firefox is fixed. At the moment, I can not set login and password to anything because this would allow my subscribers to gain access to a protected area, where only subscribers that have filled a webform with some personal information are admitted.

    I think I will have to rewrite this piece of code, maybe using 2 different MemberType for this ("subscribers" and "extended subscribers") in order to be able to limit access to the restricted area at "extended subscribers".

    Anyway, thanks a lot.

    @ Dirk and @Richard: From now I will definitely use .net membership. 

Please Sign in or register to post replies

Write your reply to:

Draft