Saving extended attribues seems not to work.

rated by 0 users
This post has 1 Reply | 2 Followers

Not Ranked
Posts 22
Points 315
Niki Hignett Posted: Mon, May 12 2008 6:41 PM

Hi All,

I'm struggling to save extended attributes... If I analyse "MyUser" in Visual Studio after SetExtendedAttribute is called - the info seems to be in place... But when I come to retrive it - there's no elements in the ExtendedAttributes array.

... can you see what I'm doing wrong?

Thanks,

Niki

P.s. can someone point me in the direction of some documentation? - I'll I seem to have found are these forums...

            // Create a user
            User MyUser = new User(SignInName);

            // Load
            IProfileBase ProfileBase = MemberRoleProfileProvider.Instance().Profiles.Create(SignInName, true);
            Profile MyProfile = new Profile(ProfileBase);
            MyUser.RefreshUserProfile(MyProfile);
            MyUser.RefreshMembershipUser(MemberRoleProfileProvider.Instance().Members.GetUser(SignInName));

            // Set
            MyUser.SetExtendedAttribute(Attribute, Value);

            // Save
            MyProfile.Save();
           
            // Update
            CommunityServer.Users.UpdateUser(MyUser);

 

  • | Post Points: 20
Top 10 Contributor
Posts 3,424
Points 65,735
CS Developers
Ben Tiedt replied on Wed, May 21 2008 12:40 PM

When creating a user and setting extended attributes, I'd suggest following this model:

User user = new User();

user.Username = UserNameTextBox.Text;
user.Email = EmailAddressTextBox.Text;
user.Password = PasswordTextBox.Text.Trim();

user.SetExtendedAttribute(KEY, VALUE);

Users.Create(user, false, false); // you may want to check that this returns CreateUserStatus.Created

Ben Tiedt's Blog

  • | Post Points: 5
Page 1 of 1 (2 items) | RSS
Powered by Community Server (Commercial Edition), by Telligent Systems

Copyright© 2008 Telligent Systems Inc. All rights reserved
CommunityServer.com  •  Telligent.com