Hi, can one of you tell me, what is wrong here? :-)
It is a partial view, and I want to retrieve the custom property of a member into a variable, because I want to do a check on it later.
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@using umbraco.cms.businesslogic.member;
@using Umbraco.Core;
@using Umbraco.Core.Services;
@{
// Find the current member
var member = Member.GetCurrentMember();
if (member != null)
{
var prop = member.getProperty("PhoneLocal").Value;
<h1>@prop</h1>
// Update the member
member.SetValue("PhoneLocal", "01234567890");
// Save the member
member.Save();
}
}
Try the below. I think you are getting the old and new Member API's mixed up. Note the correct SetProperty() method call. As a side note, you are using the old Member API. It might be best off using the new Member Service APi.
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@using umbraco
@using umbraco.cms.businesslogic.member
@{
// Find the current member
var member = Member.GetCurrentMember();
if (member != null)
{
var prop = member.GetProperty<string>("PhoneLocal");
<h1>@prop</h1>
// Update the member
member.SetProperty("PhoneLocal", "01234567890");
// Save the member
member.Save();
}
}
Let me get this straight. The example you posted above, is that the old or new member service?
It is complaining about the GetCurrentMember :-/
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0104: 'Member' is an ambiguous reference between 'Umbraco.Core.Models.Member' and 'umbraco.cms.businesslogic.member.Member'
Is this the new way then or am I completly confused/lost?
@{
// Find the current member
var membershipUser = Membership.GetUser();
if (membershipUser != null)
{
var membershipUsername = membershipUser.UserName;
var m = ApplicationContext.Services.MemberService.GetByUsername(membershipUsername);
var prop = m.getProperty("PhoneLocal").Value;
<h1>@prop</h1>
// Update the member
member.SetValue("PhoneLocal", "01234567890");
// Save the member
ApplicationContext.Services.MemberService.Save(member);
}
}
Do you only want to get data or also update it? The member service is for updating data and does direct calls to the database and can be pretty slow. It's better to use Umbraco.TypedMember which returns the member as an IPublishedContent (like content and media). This has better perfomance. More info here: http://issues.umbraco.org/issue/U4-4379#comment=67-12760
I get this error with the getproperty:
'Umbraco.Core.Models.IMember' does not contain a definition for 'getProperty' and no extension method 'getProperty' accepting a first argument of type 'Umbraco.Core.Models.IMember' could be found (are you missing a using directive or an assembly reference?)
Getting custom property from member u7
Hi, can one of you tell me, what is wrong here? :-)
It is a partial view, and I want to retrieve the custom property of a member into a variable, because I want to do a check on it later.
Thank you!
/Daniel
Hi Daniel,
Try the below. I think you are getting the old and new Member API's mixed up. Note the correct SetProperty() method call. As a side note, you are using the old Member API. It might be best off using the new Member Service APi.
Thanks, Dan.
Let me get this straight. The example you posted above, is that the old or new member service?
It is complaining about the GetCurrentMember :-/
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0104: 'Member' is an ambiguous reference between 'Umbraco.Core.Models.Member' and 'umbraco.cms.businesslogic.member.Member'
Source Error:
Line 5: @{
Line 6: // Find the current member
Line 7: var member = Member.GetCurrentMember();
Line 8:
Line 9: if (member != null)
Thank you for helping me :-)
Hi Daniel,
The way above is the old way. To fix your error now, add the following line:
Thanks, Dan.
Is this the new way then or am I completly confused/lost?
Thank you :-)
Yeah thats the new way. Take a look here for more information.
Thanks, Dan.
Hello,
Do you only want to get data or also update it? The member service is for updating data and does direct calls to the database and can be pretty slow. It's better to use Umbraco.TypedMember which returns the member as an IPublishedContent (like content and media). This has better perfomance. More info here: http://issues.umbraco.org/issue/U4-4379#comment=67-12760
Jeroen
I need to get and update data :-)
I get this error with the getproperty: 'Umbraco.Core.Models.IMember' does not contain a definition for 'getProperty' and no extension method 'getProperty' accepting a first argument of type 'Umbraco.Core.Models.IMember' could be found (are you missing a using directive or an assembly reference?)
Thank you :-)
Try...
Thanks, Dan.
Thank you very much! :-D
I hope you'll have a nice day!
/Daniel
is working on a reply...