I have asked this question on the Our Umbraco forums, however I wanted to also increase my chances of getting a solution by posting the same question here.
The issue I have is that, inside a Razor macro, I'm unable to get the current Member
who is accessing the site. I have tried the following methods:
Is there another way to get the current Member
seeing how the above methods do not work in my case?
var m = Membership.GetUser();
That should work, just verified it myself on 4.7.1; it will return NULL if you are not logged in as a member, but when you log in it should get you what you want.
Just a slight change from @E.J.Brennan if the NULL is an issue you can check if you are logged on before trying to GetUser():
if (umbraco.library.IsLoggedOn())
{
m = Membership.GetUser();
}
Starting from v7 you can use the MembershipHelper
@Members.CurrentUserName
@Members.GetCurrentMember()
@Members.GetCurrentMemberId()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With