Is it possible to add access controls to a page?

I have been looking at adding an access dropdown to the friends page so that users can select who can see their list of friends i.e. private, public, logged in users or friends. Is this possible to do using elgg functions or is it a bit more tricky than that? I have searched some plugin and looked at http://reference.elgg.org/1.8/ but am not too sure what I am looking for. 

Any help/advice would be great! 

  • The access level system works based on entities. This means you can set for example for a blog who can see this blog. But a page is no entity, so you can't use Elgg's entity access level implementation for restricting access to a page.

    You could modify the pagehandler that delivers the friends and "friends of" pages to check for certain criteria ("is user logged in?" or "is user a friend of the friend's page user?"). But this would be rather static, i.e. you would have to decide on who is allowed to see the pages for all users. Of course, you could add a user-specific access control, too. You would have to add a dropdown input field on your own version of the pages (that get used instead of the default pages by overriding the pagehandler accordingly). The selected access could be saved for example as metadata entry of the user entity. Then again the pagehandler has to be coded accordingly to either give access or deny it depending on the user metadata and the relationship between the viewer and the page owner.

  • @iionly

    That seem like alot of work so I think I will just make the friends page - for page owner only and then use the friends widget. Users can then choose access settings on the widget.

    Then I can look at it again when I have more experience/time. 

    Thanks again for your help. 

Beginning Developers

Beginning Developers

This space is for newcomers, who wish to build a new plugin or to customize an existing one to their liking