Class UmbracoUserExtensions
Provides extension methods for the IUser interface.
Inheritance
Namespace: Umbraco.Extensions
Assembly: Umbraco.Core.dll
Syntax
public static class UmbracoUserExtensions
Methods
View SourceGetPermissions(IUser, string, IUserService)
Gets the permissions for a user on a specific content path.
Declaration
public static IEnumerable<string> GetPermissions(this IUser user, string path, IUserService userService)
Parameters
| Type | Name | Description |
|---|---|---|
| IUser | user | The user to get permissions for. |
| string | path | The content path to check permissions on. |
| IUserService | userService | The user service. |
Returns
| Type | Description |
|---|---|
| IEnumerable<string> | An enumerable of permission strings. |
GetUserCulture(string?, ILocalizedTextService, GlobalSettings)
Gets the culture info for a specified language code.
Declaration
public static CultureInfo GetUserCulture(string? userLanguage, ILocalizedTextService textService, GlobalSettings globalSettings)
Parameters
| Type | Name | Description |
|---|---|---|
| string | userLanguage | The user's language code. |
| ILocalizedTextService | textService | The localized text service. |
| GlobalSettings | globalSettings | The global settings. |
Returns
| Type | Description |
|---|---|
| CultureInfo | The System.Globalization.CultureInfo for the specified language, or the default UI language if not found. |
GetUserCulture(IUser, ILocalizedTextService, GlobalSettings)
Returns the culture info associated with this user, based on the language they're assigned to in the back office
Declaration
public static CultureInfo GetUserCulture(this IUser user, ILocalizedTextService textService, GlobalSettings globalSettings)
Parameters
| Type | Name | Description |
|---|---|---|
| IUser | user | |
| ILocalizedTextService | textService | |
| GlobalSettings | globalSettings |
Returns
| Type | Description |
|---|---|
| CultureInfo |
HasSectionAccess(IUser, string)
Determines whether the user has access to the specified section (application).
Declaration
public static bool HasSectionAccess(this IUser user, string app)
Parameters
| Type | Name | Description |
|---|---|---|
| IUser | user | The user to check. |
| string | app | The section/application alias to check access for. |
Returns
| Type | Description |
|---|---|
| bool |
|
IsAdmin(IUser)
Determines whether this user belongs to the administrators group.
Declaration
public static bool IsAdmin(this IUser user)
Parameters
| Type | Name | Description |
|---|---|---|
| IUser | user |
Returns
| Type | Description |
|---|---|
| bool |
Remarks
The 'super' user does not automatically belongs to the administrators group.
IsSuper(IUser)
Determines whether this user is the 'super' user.
Declaration
public static bool IsSuper(this IUser user)
Parameters
| Type | Name | Description |
|---|---|---|
| IUser | user |
Returns
| Type | Description |
|---|---|
| bool |