How to display different appearance for different users using Confluence layouts
promising, but I don't know what the elements are all called, how to find their names, or if the elements are even hide-able
If it's ScriptRunner, just point me in the right direction, and I'll get there.
If there's some other magical way to do this, please let me know.
Thank you in advance!
To prevent a certain user group from creating, editing, replying, or liking comments in Confluence while still allowing them to view comments, you can use ScriptRunner for Confluence. Here are the steps you can follow:
Create a new Script Fragment in ScriptRunner for Confluence. This can be done by navigating to the Script Fragments section in the ScriptRunner Console.
In the Script Fragment, use the following code to hide the elements related to commenting and liking:
AJS.toInit(function(){
// Replace 'groupname' with the name of your user group
if(AJS.$('.comment').length > 0 && !AJS.$('.user-group-groupname').length){
AJS.$('.comment').remove();
AJS.$('.comment-reply').remove();
AJS.$('.comment-likes').remove();
}
});
This code will remove the elements related to commenting and liking if the user is not a member of the specified group. You can adjust the group name as needed.
Save the Script Fragment.
Create a new Layout in Confluence. This can be done by navigating to the Layouts section in the Confluence Administration console.
In the Layout, use the following code to include the Script Fragment:
#if($!remoteUser.groups.contains("groupname"))
<script src="/s/-/s/atlassian-scriptrunner-webresources/translations/latest/all.js"></script>
<script src="/s/-/s/atlassian-scriptrunner-webresources/fragments/1.0.0/run.fragment.js"></script>
#end
This code will include the Script Fragment only if the user is a member of the specified group. Again, you can adjust the group name as needed.
This approach should hide the elements related to commenting and liking for users who are not members of the specified group, while still allowing them to view comments. Note that this approach does not hide the comments altogether, so they will still be accessible via the URL. Also, you may need to adjust the code to hide page likes as well, but the basic approach should be similar.
Hi @Pankaj Jangid ,
Thank you for replying. I already have the main comments hidden though as I stated:
ScriptRunner Fragment to Hide Elements - partially works
Hid all elements with "Like" or "Comment" in the name
This only worked on the:
bottom of page comments
pop-up for inline commenting when highlighting text - it hid the comment pop-up
The ScriptRunner Fragment to Hide Elements actually already does most of the work for you, So you don't need JavaScript or to update a Layout.
I'm slowly finding round about ways of hiding the bits and pieces of Confluence for this user group that I need to. It's hacky, but so far, it's all I can come up with.
Inline comments are giving me fits.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I see, my apologies for misunderstanding. In that case, to hide inline comments for the specific user group, you can try adding custom CSS to the page. You can do this by going to the page and clicking on the "..." button in the top right corner, then selecting "Edit" > "Edit in HTML".
Once you're in the HTML editor, you can add the following CSS code to hide the inline comment button and tooltip:
/* Hide inline comment button */
a[data-type="inline-comment"] {
display: none !important;
}
/* Hide inline comment tooltip */
div[data-tooltip*="inline-comment"] {
display: none !important;
}
This should only hide the inline comment button and tooltip for the specific user group while leaving it visible for everyone else.
Note that this solution relies on CSS, so it may not be completely foolproof and could potentially be circumvented by determined users. However, it should work in most cases and is relatively simple to implement.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Pankaj Jangid ,
I'm not sure how hiding the inline comments section on one page will fit my requirements, including how it would hide for a specific group.
- Must be global, not by space or page
I'm also running Confluence Data Center 8.0.2, not Cloud. DC doesn't have ... Edit -> Edit in HTML. I know I could put it in an HTML macro, but it'd still not fit the global requirement that way.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.