I'm using the following script to hide elements of the confluence page for a specific user. However, I would like to use this for the specified user and anonymous access. How can I change this script to do this? IS it possible to have scripts that provide different views? Example, the one below for the specified user ID and another for another ID?
<script>
AJS.toInit(function(){
if (AJS.params.remoteUser == 'ctsidocs'){
AJS.$("#space-tools-menu-trigger").hide();
AJS.$('#header').hide();
AJS.$('#action-menu-link').hide();
AJS.$('#children-section').hide();
AJS.$('#shareContentLink').hide();
AJS.$('#likes-section').hide();
AJS.$('#labels-section').hide();
AJS.$('#watch-content-button').hide();
}
});
</script>
An empty remoteUser
object denotes to anonymous users
(AJS.params.remoteUser == '')
So you need to use an alternative in the if statement to have your user and anonymous access
if (AJS.params.remoteUser == 'ctsidocs' || AJS.params.remoteUser == '')
If you want to have different view for different users you need to have if.. else if.. else statement
https://www.w3schools.com/js/js_if_else.asp
You can try syntax here
https://www.w3schools.com/js/tryit.asp?filename=tryjs_elseif
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can detect logged user before rendering the view (.vm). In that you can render views (vm) according to your user level.
ApplicationUser loggedUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser();
ApplicationUser object contains Atlassian user details.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.