nickornotto
nickornotto

Reputation: 2156

umbraco membership createuser & select profile data

I have created a class to handle membership user creation with custom fields.

I have done it based on this solutions:

And now I'm trying to use create the user and get the profile data:

if (Membership.GetUserNameByEmail(email) == null)
{
MembershipUser member = Membership.CreateUser(username, password, email);

Roles.AddUserToRole(username, "WebsiteUsers");

CCL.MemberProfile currentProfile = CCL.MemberProfile.CurrentUser;

bool exists = currentProfile != null;
Response.Write(exists.ToString());
}

but currentProfile is returning null.

So I'm unable to assign values from the form to my member custom properties which are handled by the properties set in the class :(

I don't get how I can make it working :(

Does anyone have some thoughts? Thanks

Upvotes: 0

Views: 757

Answers (1)

g7876413
g7876413

Reputation: 279

Suggestion 1:

Make sure that ProfileBase.Create returns something that can be cast to a "MemberProfile", otherwise if it can't then casting it will just return NULL.

Suggestion 2:

Make sure the context you are running in has a logged in user, so your call to Membership.GetUser() can find the current user object.

Other thoughts:

The ProfileBase.Create method assumes that the username you pass in is an authenticated user, I'm not sure on it's behavior when the user isn't authenticated..maybe it returns NULL?

Upvotes: 1

Related Questions