Function to create a unique name for a newly-created Member? Options
dconlisk
Posted: Friday, March 14, 2008 3:17:30 PM
Rank: Enthusiast

Joined: 10/19/2007
Posts: 41
Location: Glasgow, Scotland
Hello everyone,

I'm making my first forays into the world of the Umbraco source code. What I require is to alter the member creation function so that the Login field is automatically filled with a unique value. This value is based on the Name as entered in the popup box when the user right clicks the Member node and chooses "Create". So, for example, if the name entered is "Joe Bloggs", I might try joe.bloggs as the username.

The important part that I need now is a way of checking this username "joe.bloggs" against all of the existing usernames already in use to ensure that it is unique. From what I can see you need an id to create a member object, but I want to loop over all of the members and compare the usernames with my new username.

Anyone got any bright ideas on how to proceed?

Many thanks,

David

http://equatorlive.com/blogs/dotnetdave/
jHodgkinson
Posted: Friday, March 14, 2008 3:24:00 PM
Rank: Fanatic

Joined: 3/15/2007
Posts: 351
Location: Cary, NC USA
I would check to see if the member name exists before actually calling the MakeNew method, i.e.

Code:


if (umbraco.cms.businesslogic.member.Member.GetMemberFromLoginName(memberName) != null)
{
     //user exists already
}
else
{
    //create new user
    umbraco.cms.businesslogic.member.Member m = umbraco.cms.businesslogic.member.Member.MakeNew(......)
(

}

dconlisk
Posted: Friday, March 14, 2008 3:35:29 PM
Rank: Enthusiast

Joined: 10/19/2007
Posts: 41
Location: Glasgow, Scotland
Hi John,

I'll try that - it looks like exactly what I need, and thank you for the quick response too! I obviously didn't look hard enough through the methods of the member class.

Cheers,

David
Users browsing this topic
Guest


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.