The example comes from an Mvc controller, so the model.Property is just an object with the infos provided by the user.
To set up the webservice in Umbraco i would recommend using UmbracoApiController if you are on Umbraco 6.1.x. But i think there should be more than one way to get somethink like a webservice up and running.
How to create members and assign to roles using API in Umbraco 6.x
Hi,
I need to create a web service that can dynamically create members and assign them to member roles.
What is the best way to do this using the API?
There is a section on the API cheatsheet ( http://our.umbraco.org/wiki/reference/api-cheatsheet/working-with-members )but it says that it is out of date and should be updated:
Thanks,
Nick
Most of the member api is marked as outdated but can be used. So just try to use the functions you need and see if they work.
Here's a sample on how you create a new user and set a membergroup to him:
//Member Type
MemberType umbJobMemberType = MemberType.GetByAlias("TMMember");
//Umbraco Admin User (The Umbraco back office username who will create the member via the API)
User umbUser = new User("dbrendel");
//Model valid let's create the member
try
{
Member createMember = Member.MakeNew(model.Name, model.EmailAddress, model.EmailAddress, umbJobMemberType, umbUser);
//Set password on the newly created member
createMember.Password = model.Password;
//Set the verified email to false
createMember.getProperty("hasVerifiedEmail").Value = false;
//Set the profile URL to be the member ID, so they have a unqie profile ID, until they go to set it
createMember.getProperty("profileURL").Value = createMember.Id;
createMember.AddGroup(MemberGroup.GetByName("TMGroup").Id);
//Save the changes
createMember.Save();
}
catch (Exception ex)
{
//EG: Duplicate email address - already exists
throw;
}
The example comes from an Mvc controller, so the model.Property is just an object with the infos provided by the user.
To set up the webservice in Umbraco i would recommend using UmbracoApiController if you are on Umbraco 6.1.x. But i think there should be more than one way to get somethink like a webservice up and running.
Hi David,
thanks for the reply. I am not too familiar with MVC and am using web forms.
Does v6 use the ASP.NET membership provider? Is there any example code for creating members and assigning them to Umbraco MemberGroup's using this?
thanks.
Hello,
The member api will get a new version, but the old api is still the best thing for now. The obsolete attributes have even been removed again in the latest version of Umbraco: https://github.com/umbraco/Umbraco-CMS/commit/7c6aee17e90d4b59a29cbcabf915475510c072c7
New member api: http://issues.umbraco.org/issue/U4-1659
So this documentation is still good: http://our.umbraco.org/wiki/reference/api-cheatsheet/working-with-members
Jeroen
Thanks Jeroen.
is working on a reply...