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.
The forum of the forums
3 posters

    BBCODE Only for Staff

    avatar
    Simone Boi
    Forumember


    Posts : 90
    Reputation : 2
    Language : Italian

    Solved BBCODE Only for Staff

    Post by Simone Boi February 8th 2021, 6:18 am

    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:
    skouliki
    skouliki
    Manager
    Manager


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

    Solved Re: BBCODE Only for Staff

    Post by skouliki February 8th 2021, 10:18 am

    hello

    did you find this code on the Italian support ?

    avatar
    Simone Boi
    Forumember


    Posts : 90
    Reputation : 2
    Language : Italian

    Solved Re: BBCODE Only for Staff

    Post by Simone Boi February 8th 2021, 10:33 am

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


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

    Solved Re: BBCODE Only for Staff

    Post by TheCrow February 8th 2021, 10:42 am

    @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!

    SarkZKalie and Simone Boi like this post

    avatar
    Simone Boi
    Forumember


    Posts : 90
    Reputation : 2
    Language : Italian

    Solved Re: BBCODE Only for Staff

    Post by Simone Boi February 8th 2021, 10:55 am

    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?
    TheCrow
    TheCrow
    Manager
    Manager


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

    Solved Re: BBCODE Only for Staff

    Post by TheCrow February 8th 2021, 11:00 am

    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!

    Simone Boi likes this post

    avatar
    Simone Boi
    Forumember


    Posts : 90
    Reputation : 2
    Language : Italian

    Solved Re: BBCODE Only for Staff

    Post by Simone Boi February 8th 2021, 11:50 am

    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
    skouliki
    skouliki
    Manager
    Manager


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

    Solved Re: BBCODE Only for Staff

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

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


      Current date/time is November 11th 2024, 2:49 pm