Jump to content

How to restrict edit access (in back end admin) by page ID?


modifiedcontent
 Share

Recommended Posts

I want to give members of my site access to their profile page edit in admin, but I don't want them to go up the tree and start editing other members pages - which is what could happen if I control access by the template 'profile' only. 

How can I make sure members can only edit their own profile page?

In the profile template, for the front end, I have something like `if ( $user->isLoggedin() && $user->name == $page->name )` to restrict edit access to the page owner. In the back end there are parameters on the URL, like admin/page/edit/?id=1388

How can I target that? I can get the currently logged-in user's profile page ID; if they are trying to edit another page ID, they should be blocked/redirected. Can I add something in admin.php to achieve that?

I see Ryan Cramer has a PageEditPerUser module, but it is very old, very beta and requires to enter allowed pages manually.

AdminRestrictBranch seems more stable and has a Custom PHP option - trying to figure that out now... 

Link to comment
Share on other sites

Thanks for the response @Jan Romero. I was looking in that direction. I think 'profile-edit' is for admin/profile/, which is based on the system 'user' template. I use another 'profile' template for pages created when members register with the site.

Today I have tried to figure out if I could replace that 'profile' template by the 'user' template, but I can't make it work for some reason.

I can just keep using 'profile' I guess and get all the content from 'user' anyway, but is there any way to edit the template of /admin/profile/? The use of the (user)name instead of First Lastname annoys me. And I'd like to replace the Processwire logo/icon with the site + homelink etc.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...