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.

Warning button help

2 posters

Go down

Solved Warning button help

Post by _Twisted_Mods_ October 24th 2014, 12:57 am

ok ange how do i setup your code so only users of that lvl can see the buttons

like admin can only see admin button,mods only see mod button?
_Twisted_Mods_
_Twisted_Mods_
Helper
Helper

Male Posts : 2083
Reputation : 336
Language : English
Location : Ms

http://liquidcode.forumotion.com

Back to top Go down

Solved Re: Warning button help

Post by Ange Tuteur October 24th 2014, 1:19 am

Hello,

You're referring to this tuto ?
https://help.forumotion.com/t136169-warning-button-for-administrators-and-moderators

If so, by default Admins can see the admin/mod buttons, and users with moderation rights can only see the mod button.
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13207
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

Solved Re: Warning button help

Post by _Twisted_Mods_ October 24th 2014, 1:33 am

yes....


i know but i wanna add more groups and only have each group see theres including admin
_Twisted_Mods_
_Twisted_Mods_
Helper
Helper

Male Posts : 2083
Reputation : 336
Language : English
Location : Ms

http://liquidcode.forumotion.com

Back to top Go down

Solved Re: Warning button help

Post by Ange Tuteur October 24th 2014, 2:22 am

Okay, see if this works :

I've made some modifications for making buttons for groups.


Administration Panel > Modules > JavaScript codes management > Create a new script

Title : Your choice
Placement : In all the pages
Code:
$(function() {
  // custom buttons
  groupButton([1, 2, 3], 'test', 'http://i39.servimg.com/u/f39/18/21/41/30/bouton10.png');
  
  function groupButton(users, tagname, image) {
    for (i=0; i<users.length; i++) {
      if (users[i] === _userdata.user_id) {
        $("#text_editor_textarea").before("<img src='"+image+"' title='Warning' id='"+tagname+"-b'/>");
        $('#'+tagname+'-b').click(function(){$('#text_editor_textarea').sceditor('instance').insertText('['+tagname+']','[/'+tagname+']')});
      }
    }
    var reg = new RegExp('\\['+tagname+'\\](.+?)\\[/'+tagname+'\\]','ig');
    $('div.postbody div').each(function () {if ($(this).text().indexOf('['+tagname+']') != -1) $(this).html($(this).html().replace(reg, '<div class="'+tagname+'_mess"><div class="titl">Warning</div><div>$1 </div></div>'))});
  }
});

Under the comment // custom buttons, you can write the following function to create new buttons : groupButton(users, tagname, image);

users : Takes an array. In the array insert the user ID of the users you want to view the button.
Example groupButton([1, 23, 6, 188], tagname, image);

tagname : Takes a string value. Insert the name of the tag.
Example groupButton([1, 23, 6, 188], 'tag', image);
[tag] ... [/tag]

image : Takes a string value. Insert the image that will be used as the button.
Example groupButton([1, 23, 6, 188], 'tag', '/myimage.gif');
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13207
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

Solved Re: Warning button help

Post by _Twisted_Mods_ October 24th 2014, 4:00 am

no seems to be some kinda bug when i add more then the 2 groups

none of the buttons show up for the other groups unless i change the # to 2 even tho they are not in group 2
_Twisted_Mods_
_Twisted_Mods_
Helper
Helper

Male Posts : 2083
Reputation : 336
Language : English
Location : Ms

http://liquidcode.forumotion.com

Back to top Go down

Solved Re: Warning button help

Post by Ange Tuteur October 24th 2014, 4:22 am

In the first argument (users), are you inserting the user ID of that group member ?

Example :
I am 88576 https://help.forumotion.com/u88576

So I would write my ID, plus others separated by a comma.
Code:
groupButton([88576], 'test', 'http://i39.servimg.com/u/f39/18/21/41/30/bouton10.png');
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13207
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

Solved Re: Warning button help

Post by _Twisted_Mods_ October 24th 2014, 4:24 am

oh thought it was doing it by group # not member #
_Twisted_Mods_
_Twisted_Mods_
Helper
Helper

Male Posts : 2083
Reputation : 336
Language : English
Location : Ms

http://liquidcode.forumotion.com

Back to top Go down

Solved Re: Warning button help

Post by Ange Tuteur October 24th 2014, 4:30 am

Yep, you must create an array of UIDs. There's no way to check groups that I know of, so this is the next best way. Smile
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13207
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

Solved Re: Warning button help

Post by _Twisted_Mods_ October 24th 2014, 4:31 am

what about doing it by rank_title
_Twisted_Mods_
_Twisted_Mods_
Helper
Helper

Male Posts : 2083
Reputation : 336
Language : English
Location : Ms

http://liquidcode.forumotion.com

Back to top Go down

Solved Re: Warning button help

Post by Ange Tuteur October 24th 2014, 4:36 am

You could use _lang.rank_title however, that data requires the toolbar to be active. Also if it contains HTML you need to compare it with the HTML.

ex :
Code:
if (_lang.rank_title === '<span style="color:#f00">my</span> rank') console.log(true);
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13207
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

Solved Re: Warning button help

Post by _Twisted_Mods_ October 24th 2014, 4:37 am

dang ok ill use the way with the usernames ....ty


Solved
_Twisted_Mods_
_Twisted_Mods_
Helper
Helper

Male Posts : 2083
Reputation : 336
Language : English
Location : Ms

http://liquidcode.forumotion.com

Back to top Go down

Solved Re: Warning button help

Post by Ange Tuteur October 24th 2014, 4:39 am

You're welcome ^^

Topic archived
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13207
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

Back to top

- Similar topics

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