The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

BBCODE Only for Staff

3 posters

Go down

Solved BBCODE Only for Staff

Post by Simone Boi February 8th 2021, 2:18 pm

Hi guys! Like always I want to thank you all for helping me.

Today my question is about BBCode.

I added these BBCode with a nice look:

BBCODE Only for Staff GMTQ9kC

and buttons:

BBCODE Only for Staff BkeB4Ox

But how can make them work only for staff? (admin+moderators)
I want that guest or normal users can't see the bbcode buttons in SCeditor, and they can't even manually add them just typing the code "[success=Risolto][/success]"

Is that possible?

Here's the codes:

Spoiler:
avatar
Simone Boi
Forumember

Posts : 90
Reputation : 2
Language : Italian

https://gamespledge.forumattivo.com/

Back to top Go down

Solved Re: BBCODE Only for Staff

Post by skouliki February 8th 2021, 6:18 pm

hello

did you find this code on the Italian support ?
skouliki
skouliki
Manager
Manager

Female Posts : 15404
Reputation : 1709
Language : English,Greek
Location : Greece

http://iconskouliki.forumgreek.com

Back to top Go down

Solved Re: BBCODE Only for Staff

Post by Simone Boi February 8th 2021, 6:33 pm

Hi! Actually i don't remember, I followed a tutorial long time ago, but I don't think was on the italian forum.
avatar
Simone Boi
Forumember

Posts : 90
Reputation : 2
Language : Italian

https://gamespledge.forumattivo.com/

Back to top Go down

Solved Re: BBCODE Only for Staff

Post by TheCrow February 8th 2021, 6:42 pm

@Simone Boi replace the first script you posted with this one:
Code:
jQuery(function(){

      if (_userdata.user_level === 0 || !document.getElementById('text_editor_textarea')) return;

      jQuery(function(){
        jQuery('<a class="sceditor-button sceditor-button-sucesso" unselectable="on" title="Sucesso"><div unselectable="on" style="background-image:url(https://i.imgur.com/EISZPwN.png)">Sucesso</div></a>').insertBefore('.sceditor-button-size').click(function(){
                jQuery('#text_editor_textarea').sceditor("instance").insertText("[success=Risolto]","[/success]");
        });
        jQuery('<a class="sceditor-button sceditor-button-alerta" unselectable="on" title="Alerta"><div unselectable="on" style="background-image:url(https://i.imgur.com/lMsD0nE.png)">Alerta</div></a>').insertAfter('.sceditor-button-sucesso').click(function(){
                jQuery('#text_editor_textarea').sceditor("instance").insertText("[alert=Avverimento]","[/alert]");
        });
        jQuery('<a class="sceditor-button sceditor-button-aviso" unselectable="on" title="Aviso"><div unselectable="on" style="background-image:url(https://i.imgur.com/cI8SnOI.png)">Aviso</div></a>').insertAfter('.sceditor-button-alerta').click(function(){
                jQuery('#text_editor_textarea').sceditor("instance").insertText("[warn=Attenzione]","[/warn]");
        });
        jQuery('<a class="sceditor-button sceditor-button-info" unselectable="on" title="Informação"><div unselectable="on" style="background-image:url(https://i.imgur.com/40zM1qS.png)">Informação</div></a>').insertAfter('.sceditor-button-aviso').click(function(){
                jQuery('#text_editor_textarea').sceditor("instance").insertText("[info=Informazioni]","[/info]");
        });
        });
      });

That should make the buttons appear only to moderators. The addition to it is the 3rd line in there.
Code:
if (_userdata.user_level === 0 || !document.getElementById('text_editor_textarea')) return;
This
Code:
if
check, is looking for ordinary members. If the member has level 0 (which is simple members) it returns the editor as the default one. Otherwise it adds the buttons for members who are moderators or administrators.

I hope this is what you were looking for.

Regards,
TC.


BBCODE Only for Staff Thecro10
Forum of the Forums

Forumotion Rules | Tips & Tricks |
FAQ | Did you forget your password?



*** The Support Forum will never ask you for your email or password, so please do not post them anywhere! ***
No support via PM!
TheCrow
TheCrow
Manager
Manager

Male Posts : 6916
Reputation : 795
Language : Greek, English

https://www.inforumgr.com

SarkZKalie and Simone Boi like this post

Back to top Go down

Solved Re: BBCODE Only for Staff

Post by Simone Boi February 8th 2021, 6:55 pm

Hi TheCrow! That worked for buttons, thanks a lot! But if an user type the code manually, like "[success=Risolto][/success]", without using the button, still gets the effect, there is a way to negate the code for no-staff users?
avatar
Simone Boi
Forumember

Posts : 90
Reputation : 2
Language : Italian

https://gamespledge.forumattivo.com/

Back to top Go down

Solved Re: BBCODE Only for Staff

Post by TheCrow February 8th 2021, 7:00 pm

You cannot prevent someone from typing it manually. That will affect your quotes and all afterwards.

If for example, you type the yellow one to say Please don't double post and I use the quote to say Sorry it won't happen again. in the quote it will display as bbcode and not as quote because it is taken as if the member is typing it manually. Therefore that would make a little mess.

My suggestion to you would be to have them as they are now, and if someone uses them, give a fair warning not to use them again otherwise there will be punishments as they are only reserved for staff.

Regards,
TC.


BBCODE Only for Staff Thecro10
Forum of the Forums

Forumotion Rules | Tips & Tricks |
FAQ | Did you forget your password?



*** The Support Forum will never ask you for your email or password, so please do not post them anywhere! ***
No support via PM!
TheCrow
TheCrow
Manager
Manager

Male Posts : 6916
Reputation : 795
Language : Greek, English

https://www.inforumgr.com

Simone Boi likes this post

Back to top Go down

Solved Re: BBCODE Only for Staff

Post by Simone Boi February 8th 2021, 7:50 pm

Oh, I guess I should just do like you say then, hope there will be a way to prevent users from use it in future, anyway thank you a lot! Atleast I can hide buttons! I love you I love you I love you
avatar
Simone Boi
Forumember

Posts : 90
Reputation : 2
Language : Italian

https://gamespledge.forumattivo.com/

Back to top Go down

Solved Re: BBCODE Only for Staff

Post by skouliki February 8th 2021, 8:29 pm

Problem solved & topic archived.
Please read our forum rules: ESF General Rules
skouliki
skouliki
Manager
Manager

Female Posts : 15404
Reputation : 1709
Language : English,Greek
Location : Greece

http://iconskouliki.forumgreek.com

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum