Previously I have tried to set a specific LoginName for a Member when they are created using the create events. This didn't seem to work, as umbraco sets the LoginName itself after all other events has been fired. In umbraco 4.0.3 the follwing fix was included:
25519 Add event when creating member in UI
I had hoped that this fix would solve my problem.
I am trying both in the Member.New and the Member.AfterNew event to set the LoginName and save the member, but umbraco still keeps overwriting the LoginName after all events has been fired when a member is created. Additionally the Member.AfterNew event seems to fire before the Member.New event.
Does anyone know of any way to achieve this?
Basically I want a user with the name "Dennis Milandt" to have the LoginName "dennis.milandt" - umbraco enforces the LoginName when the member is created to "dennismilandt". How do I override this?
Can't you override the CreateUser() method? Users are also based on membership provider, so, if you inherit from users membership provider already implemented in umbraco, and just override the CreateUser() method. (Just theoretically, haven't tried it myself)
Are you talking about Users or Members? I am using the umbraco backoffice ui to create a new Member, and wants to set the LoginName myself using the Member events.
How can I override the CreateUser() method? In the umbraco source code? How do I get umbraco to call my CreateUser() method instead?
You're right, we should be talking 'bout members, but principle is quite the same. You'd need to create a custom membership provider, probably inheriting from the umbraco membership provider class and only override the CreateUser() method. You don't need to call the CreateUser() method yourself, that's done by the asp.net runtime when using the asp.net membership controls (if you use those of course)
Hi Dennis, I think you're looking for something like this:
// adding users to default roles when creating the user
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
CreateUserWizard1.CreatedUser += new EventHandler(CreateUserWizard1_CreatedUser);
}
// event call to add the user role...
void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
{
Member registeredMember = Member.GetMemberFromLoginName(CreateUserWizard1.UserName);
// try to save the entire profile with all the data that we filled in...
if (registeredMember != null && registeredMember.Id > 0) {
try {
//Member profile update based on info found in registration wizard
UpdateMember(registeredMember);
} catch {
Log.Add(LogTypes.Custom, User.GetUser(0), Node.GetCurrent().Id,
new StringBuilder().Append("Error while persisting member profile info for member '").Append(registeredMember.Text).Append("' (").Append(registeredMember.Id).Append(")!").ToString());
}
}
CreateUserWizard1.LoginCreatedUser = false;
}
Then in your "UpdateMember" method, you can set and save the member details from there:
private void UpdateMember(Member member)
{
// do member stuff and save the member
member.LoginName="my login name..."; // set member name here...
member.Save(); // save umbraco member properties
}
Hopefully this will get you going in the right direction.
I have just implemented a new Create dialog in the Members section. You can now set the login for the user seperately from their name. This will be included in version 4.5.2 The login name and the email are also verified to be unique and not in the db. member is not created if either is not unique.
also you should use the memberTasks.NewMember event in the UI This fires are the loginname & password are set. Member.New fires as soon as the member node is created, before the loginname or password are set.
Setting the Member LoginName on create
Previously I have tried to set a specific LoginName for a Member when they are created using the create events. This didn't seem to work, as umbraco sets the LoginName itself after all other events has been fired. In umbraco 4.0.3 the follwing fix was included:
25519 Add event when creating member in UI
I had hoped that this fix would solve my problem.
I am trying both in the Member.New and the Member.AfterNew event to set the LoginName and save the member, but umbraco still keeps overwriting the LoginName after all events has been fired when a member is created. Additionally the Member.AfterNew event seems to fire before the Member.New event.
Does anyone know of any way to achieve this?
Basically I want a user with the name "Dennis Milandt" to have the LoginName "dennis.milandt" - umbraco enforces the LoginName when the member is created to "dennismilandt". How do I override this?
Kind regards
Dennis Milandt
BUMP.
/Dennis
Can't you override the CreateUser() method? Users are also based on membership provider, so, if you inherit from users membership provider already implemented in umbraco, and just override the CreateUser() method. (Just theoretically, haven't tried it myself)
Cheers,
/Dirk
Are you talking about Users or Members? I am using the umbraco backoffice ui to create a new Member, and wants to set the LoginName myself using the Member events.
How can I override the CreateUser() method? In the umbraco source code? How do I get umbraco to call my CreateUser() method instead?
/Dennis
You're right, we should be talking 'bout members, but principle is quite the same. You'd need to create a custom membership provider, probably inheriting from the umbraco membership provider class and only override the CreateUser() method. You don't need to call the CreateUser() method yourself, that's done by the asp.net runtime when using the asp.net membership controls (if you use those of course)
Let me know if this is still unclear.
Cheers,
/Dirk
Hi Dennis, I think you're looking for something like this:
Then in your "UpdateMember" method, you can set and save the member details from there:
Hopefully this will get you going in the right direction.
-- Nik
...or, like Dirk sugst you can create your own Membership provider like:
And then your class would look something like:
Just another flavor...
Cheers...
Dirk and Nick: Thank you very much for your answers and details.Much appreciated.
A custom membership provider it is then :-)
/Dennis
Hi Dennis
Did this work for you?
Does the administrator's tool in the umbraco admin use the membership provider when it creates members?
I have just implemented a new Create dialog in the Members section. You can now set the login for the user seperately from their name. This will be included in version 4.5.2 The login name and the email are also verified to be unique and not in the db. member is not created if either is not unique.
also you should use the memberTasks.NewMember event in the UI This fires are the loginname & password are set. Member.New fires as soon as the member node is created, before the loginname or password are set.
is working on a reply...