Applies to Umbraco 7.1 and 6.2 and newer
The MemberService acts as a "gateway" to Umbraco data for operations which are related to Members.
Browse the API documentation for MemberService.
- Namespace:
Umbraco.Core.Services - Assembly:
Umbraco.Core.dll
All samples in this document will require references to the following dll:
- Umbraco.Core.dll
All samples in this document will require the following usings:
using Umbraco.Core;
using Umbraco.Core.Models;
using Umbraco.Core.Services;
Please note that this page will be updated with samples and additional information about the methods listed below
The MemberService is available through the ApplicationContext, but the if you are using a SurfaceController or the UmbracoUserControl then the MemberService is available through a local Services property.
Services.MemberService
Getting the service through the ApplicationContext:
ApplicationContext.Current.Services.MemberService
Adds a new Role with a given name
Assigns a role to a specific Member
Assigns a role to multiple Members
Creates a new Member, but does not instantly persist it
.CreateMemberWithIdentity(string username, string email, string displayName, string memberTypeAlias);
Creates a new Member, persists the data, and assign a unique key
Creates a new Member with a given password, persists the data, and assign a unique key
Deletes a Member
Deletes all members of a given type
Deletes a role, define if deletion should throw an exception if the role is in use by any members
Removes the role from a given Member
Removes multiple roles from multiple Member s
Returns true/false if a gven member ID exists
Returns true/false if a gven member login exists
.FindByEmail("gmail.com", int pageIndex, int pageSize, out int totalRecords, [StringPropertyMatchType]);
Searches for all members with a given email, supports paging returned results.
Search supports multiple match types:
- Exact email must be equal to term
- Contains email must contain term
- StartsWith email must start with term
- EndsWith email must end with term
- Wildcard email must match wildcard string like "mail."
.FindByUsername(string username, int pageIndex, int pageSize, out int totalRecords, [StringPropertyMatchType]);
Searches for all members with a given username, supports paging returned results.
Search supports multiple match types:
- Exact username must be equal to term
- Contains username must contain term
- StartsWith username must start with term
- EndsWith username must end with term
- Wildcard username must match wildcard string like "j*n"
.FindMembersByDisplayName(string name, int pageIndex, int pageSize, out int totalRecords, [StringPropertyMatchType]);
Searches for all members with a given display name, supports paging returned results.
Search supports multiple match types:
- Exact display name must be equal to term
- Contains display name must contain term
- StartsWith display name must start with term
- EndsWith display name must end with term
- Wildcard display name must match wildcard string like "j*n"
Searches for all members with a given username with a given Role assigned.
Search supports multiple match types:
- Exact username must be equal to term
- Contains username must contain term
- StartsWith username must start with term
- EndsWith username must end with term
- Wildcard username must match wildcard string like "j*n"
Returns all members, in paged results.
Returns a collection of members with the given ID's
Returns all roles
Returns a single Member with a given Email
Returns a single Member with a given ID
Returns a single Member with a given Key
Returns a single Member with a given Membership provider key.
Returns a single Member with a given Username
Returns the default MemberType
Returns all members in a given Group - same as "Role".
Returns all members of a given Type
Returns all Members, of any type, with a mathcing value in the property with the given property alias
Returns all members in a given Role
Saves a Member,
Sets a password on a given Member