Attention:

Support Rules and Guidelines
Before you post your support topic, please remember to:
  • Read the support forum rules.
  • Check the wiki and use search to see if your problem can be answered there first.
  • Link your board please, and make sure that the problem on your board is visible to guests or provide a test account.
  • Do not post Board Wrappers and CSS unless requested. With a board link, this is not necessary.
  • Be as descriptive as you can and use as many details as possible when describing your problem.
  • Please briefly mark any links to forums that may not be work-safe.
This will help ensure your support issue will be attended to in a quick and efficient manner.

  Add ReplyNew TopicNew Poll

 Hiding Custom BBCode Buttons from specific groups?
#
I made several custom BBCode templates for staff to use on my site, and would like to keep the buttons on the posting form so that we don't have to type them out every time we have to use one of these templates. I also only want my admin group to see them.

As you can see here (click), guests (along with all other groups) are able to see the code buttons as well. I've tried targeting them with javascript, though I'm getting snagged and can't figure it out.

CODE
       <script>
           // Hide custom BBCode Buttons from non-admins, extra comments will be removed once I have this cleaned up and working
           // Accept Tag - #bbcode-buttons input:nth-child(17)
           // Pend Tag - #bbcode-buttons input:nth-child(18)
           // General Template Tag - #bbcode-buttons input:nth-child(19)

           if('<!-- |g_id| -->' != '4') {
               document.getElementById('bbcode-buttons')[17].style.display = 'none';
               document.getElementById('bbcode-buttons')[18].style.display = 'none';
               document.getElementById('bbcode-buttons')[19].style.display = 'none';
           }
           else if('<!-- |g_id| -->' == '4') {
               document.getElementById('bbcode-buttons')[17].style.display = 'inline';
               document.getElementById('bbcode-buttons')[18].style.display = 'inline';
               document.getElementById('bbcode-buttons')[19].style.display = 'inline';
           }
       </script>
PM
#
1. Are you open to accomplishing this with CSS, or are you hoping to get your Javascript debugged?

2. Do you want just admins to see this, or just mods and admins?

signature
Kindly do not contact me on Discord or PM me for support.

user posted image
#
I'm open to CSS or javascript, js was the first I thought of though so just kinda ran with it.

Just the admin group.

Edit: If CSS is more compact though I'd love a pure CSS solution to this, owl

This post has been edited by kjrod98: Feb 3 2018, 04:21 PM
PM
#
You have several classes attached to your page body (in the board wrappers). If you need more help with this step let me know, but add the following as an additional class to what you have now:

bbc-<!-- |g_access_cp| -->

Then add the following to your CSS:

CODE
#bbcode-buttons > input:nth-child(16), #bbcode-buttons > input:nth-child(17), #bbcode-buttons > input:nth-child(18) {display: none}
.bbc- 1 #bbcode-buttons > input:nth-child(16), .bbc- 1 #bbcode-buttons > input:nth-child(17), .bbc- 1 #bbcode-buttons > input:nth-child(18) {display: inline}


I'm not sure if it's more compact than Javascript, but theoretically it should work. 🤞

signature
Kindly do not contact me on Discord or PM me for support.

user posted image
#
So, when testing the above I forgot to switch the skin on the character account I was switching to, definitely didn't have enough coffee this morning.

Anyways, it works like a charm. Thank you, owl!
PM
#
So glad it worked! Good luck with your forum. ^^

signature
Kindly do not contact me on Discord or PM me for support.

user posted image
0 User(s) are reading this topic (0 Guests and 0 Anonymous Users)
0 Members:
Share this topic:
« Next Oldest | General Support | Next Newest »

Options Add ReplyNew TopicNew Poll