I am creating a community website where when a user joins they get a profile page that they can update. I have created a doc type for the profile page and a user control that can edit the data in the document.
What I want to do now is to modify the profile template so that if a logged in user visits their own profile page, they should see an edit button. I can easily check if a user is logged in, but what is the best practice way of identifying whether the page belongs to that member?
Should I do something as simple as adding an extra attribute to the profile doc type tostore the members user id, or is there a better way of doing it in Umbraco?
it should be one of your options and probably the easiest to implement. If the profile edit template page is different from the profile page, you could use the public access feature (you could set the public access programmatically using the api), but still think this would be some overkill here.
I'd go with your solution, most straightforward to implement imho.
Thanks for the response Dirk. I ended up doing it that way last night using Razor and it was really easy. Now when a user signs up, i programatically create the profile page, set thier username and then just check in the front end using the code below.
User owned content - best practice
Hi
I am creating a community website where when a user joins they get a profile page that they can update. I have created a doc type for the profile page and a user control that can edit the data in the document.
What I want to do now is to modify the profile template so that if a logged in user visits their own profile page, they should see an edit button. I can easily check if a user is logged in, but what is the best practice way of identifying whether the page belongs to that member?
Should I do something as simple as adding an extra attribute to the profile doc type tostore the members user id, or is there a better way of doing it in Umbraco?
Thanks in advance for your help.
bayshield,
it should be one of your options and probably the easiest to implement. If the profile edit template page is different from the profile page, you could use the public access feature (you could set the public access programmatically using the api), but still think this would be some overkill here.
I'd go with your solution, most straightforward to implement imho.
Cheers,
/Dirk
Thanks for the response Dirk. I ended up doing it that way last night using Razor and it was really easy. Now when a user signs up, i programatically create the profile page, set thier username and then just check in the front end using the code below.
@if(@User.Identity.IsAuthenticated && @User.Identity.Name == @Model.userName)
{
//Display editing options here.
}
is working on a reply...