Update the permissions of a comment without having to refresh the page.


I am developing a plugin that allows the user to add a some features when adding a comment to a photo. I want that this user can not comment on that photo again. Therefore, I have modified the permissions of the comment so that when the user comments on a photo, he/she can no longer comment on it again. The problem is that when I modify the permissions, they are not updated until the user reloads the page. Therefore, if he/she does not refresh it, the comment interface is not disappearing.

To modify the permissions I have added a new function using elgg_register_plugin_hook_handler('permisions_check::comment', ...

This function returns false when the comment has attached a photo and the user and the user has already added a comment.

I would like to know if there is any way to force the verification of permissions without having to refresh the page.

  • Check this permission in /action/comment/add to return false if user will comment on a photo again.

    You can use AJAX for this.

    In UI use JS to hide comment form after adding a comment to a photo.