How do I disable the create page button along with the template button?
Asked by Jarvin Li:

Hi!  

I need to disable the create button along with the template button for specific groups.

Any tips would be appreciated.  

Thanks!


Answers:
author: Christo Mastoroudes _Adaptavist_
body: Hi,

You can achieve this with some javascript. Some coding knowledge is required.

You need to navigate to Confluence Administration -\> Custom HTML.

In the head section you will have to write some javascript. The next bit of code will hide the create button for all users:

```
<script type="text/javascript">
AJS.toInit(function(){
    AJS.$('#quick-create-page-button').hide();
});
</script>
```

All javascript code will have to be between the \<script\> tags.

If you want to hide the button for specific groups it becomes a little harder. But you will need to do the following logic steps.

1. Get the current user: something like this:

```
var userName = AJS.params.currentUserFullname;
```

2. Once you have the username do a rest call to find out which groups the user belongs to

```
AJS.$.ajax({ dataType: 'json', contentType: 'application/json', type: 'GET', url: AJS.params.baseUrl + '/rest/api/user/memberof?username=userName', success: function(groupData){    //evaluate groupData and put code here to show or hide the buttons }});
```

The code above is not perfect or tested, but should be close to what you need.

If this answers your question please mark it as resolved.

comments: author: Jarvin Li
body: Hi there, I did the first option you presented. There is a bit of a problem though, I was curious and tried viewing the menu bar with inspect element, and i could still show the button by changing the code.  

Is there a way for me to hide it and not let anybody see it in inspect element?


author: Christo Mastoroudes _Adaptavist_
body: Hi,

Try .remove() instead of .hide().

<https://api.jquery.com/remove/>


author: Max Foerster - K15t
body: Hi Jarvin,

is this system-wide or for a space? Can't you solve that using the default space permissions and NOT granting them the "add pages" permission?

Best, Max

comments: author: Jarvin Li
body: Hi Max,

It's system wide, we are also using a macro called Scaffolding, if I disable the permission it also disables the ability to edit the content of a page. I only need to disable the creation of a page.

Regards,

Jarvin


author: Nic Brough -Adaptavist-
body: That's correct. Create page and Edit are the same permission.


author: Chris
body: Also for those just wanting the quick create button to be hidden and the create from template to be used**only for Dashboards** you can insert the below under the **Edit Site Layouts\>Global Layouts**.

Make sure your inserting this in between "#if ($mode == "dashboard") and #else

```
<script type="text/javascript">
 AJS.toInit(function(){
 AJS.$('#quick-create-page-button').hide();
 AJS.$('#create-page-button > span.aui-iconfont-more').removeClass("aui-icon aui-icon-small aui-iconfont-more");
 });
</script>
<style>
#create-page-button {
 border-bottom-left-radius: 3.01px;
 border-top-left-radius: 3.01px;
}
</style>
```

comments: author: Andreas Gratz
body: Hi!  
Would this also work for the Cloud?  
Best,

Andreas


Tags: questions-for-confluence