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 ?
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.
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)
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).
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?)
@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.
adding a Member to a MemberGroup doesn't reflect in back-end
Hello there,
I'm using
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
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.
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
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
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).
Hey Lee,
Testing on IE8 and Safari, the field "Login" is blank (as it should) but in FF it is set to admin !!!
Weird.
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.
@Lee: it's autocomplete http://support.mozilla.com/en-US/kb/Form+autocomplete
@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.
is working on a reply...