Did you ever resolve this? I've just completed a v7 upgrade and have the same issue. I tried changing the property type to Umbraco.TrueFalse but still it just displays as Umbraco.NoEdit with no ability to unlock a member.
Whilst this isn't ideal it does seem to do the job for the moment. What I have done is hook into the EditorModelEventManager.SendingMemberModel event and change the view from readonlyvalue to boolean as follows:
private void EditorModelEventManager_SendingMemberModel(System.Web.Http.Filters.HttpActionExecutedContext sender, EditorModelEventArgs<global::Umbraco.Web.Models.ContentEditing.MemberDisplay> e)
{
var currentUsersGroups = e.UmbracoContext.Security.CurrentUser.Groups.ToList();
var isMembershipAdmin = currentUsersGroups.Exists(x =>
x.Alias.Equals("membershipAdministrator", StringComparison.OrdinalIgnoreCase));
foreach (var p in e.Model.Properties)
{
if (p.Alias.Equals("umbracoMemberLockedOut") && isMembershipAdmin)
{
p.View = "boolean";
}
}
}
To provide some further context, the reason this appears to be necessary is because the core is forcing the view to be readonlyvalue in the MemberModelMapper class:
{
//it's a generic provider so update the locked out property based on our known constant alias
var isLockedOutProperty = result.SelectMany(x => x.Properties).FirstOrDefault(x => x.Alias == Constants.Conventions.Member.IsLockedOut);
if (isLockedOutProperty?.Value != null && isLockedOutProperty.Value.ToString() != "1")
{
isLockedOutProperty.View = "readonlyvalue";
isLockedOutProperty.Value = _localizedTextService.Localize("general/no");
}
}
else
{
var umbracoProvider = (IUmbracoMemberTypeMembershipProvider)provider;
//This is kind of a hack because a developer is supposed to be allowed to set their property editor - would have been much easier
// if we just had all of the membeship provider fields on the member table :(
// TODO: But is there a way to map the IMember.IsLockedOut to the property ? i dunno.
var isLockedOutProperty = result.SelectMany(x => x.Properties).FirstOrDefault(x => x.Alias == umbracoProvider.LockPropertyTypeAlias);
if (isLockedOutProperty?.Value != null && isLockedOutProperty.Value.ToString() != "1")
{
isLockedOutProperty.View = "readonlyvalue";
isLockedOutProperty.Value = _localizedTextService.Localize("general/no");
}
}
Show umbracoMemberLockedOut as a checkbox instead of string?
Hi all!
I'm looking for a way to show the umbracoMemberLockedOut property of a member as a checkbox in the backend?
The membertype looks like this:
While the property on the member itself is a readonly string
I would like to be able to set this property from the backend without introducing a new property, is this possible?
Did you ever resolve this? I've just completed a v7 upgrade and have the same issue. I tried changing the property type to Umbraco.TrueFalse but still it just displays as Umbraco.NoEdit with no ability to unlock a member.
Whilst this isn't ideal it does seem to do the job for the moment. What I have done is hook into the
EditorModelEventManager.SendingMemberModel
event and change the view fromreadonlyvalue
toboolean
as follows:To provide some further context, the reason this appears to be necessary is because the core is forcing the view to be
readonlyvalue
in theMemberModelMapper
class:https://github.com/umbraco/Umbraco-CMS/blob/7447cc4b7eb2c66f2ba4ecba02d0dbdfbbab2d4f/src/Umbraco.Web/Models/Mapping/MemberModelMapper.cs#L281
is working on a reply...