Sign Up! Login: Password: New User? Forgot? Support
Top Mods!
Wowhead Search
by sonofsamedi
Digital Clock
by Wolfar15
Admin Forums
Welcome to the GuildPortal Help Community! These forums are for admin-to-admin help.
Available Forums
Mottie (MVP) 2/21/2011 12:50 PM EST : Widget Access Levels
GuildPortal MVP
Mottie
Posts: 3883
Zomgawsh Poster

Widget Access Levels

This script will allow you to have a widget that is only visible to guild members or one only visible to officers, etc. Essentially, you hide ALL of your widgets, then this code will sort through the titles to find matches, then figure out which ones to show.

The main problem with this script is that if someone knows what to look for, they can find and view this hidden information. So it's not perfect. The best place for information you don't want visible to others would be to add an entire page only visible to users with that access level.

Code
  • CSS: Add the following css to your custom css (Control Panel > Custom HTML & Script > Custom CSS > CSS Additions to Standard). It will hide all of the widgets on your page.
    .gpWidget { display: none; }
  • Script: Add this script to your custom script area (Control Panel > Custom HTML & Script > Custom Javascript/JQuery > Additional Functions tab). Make sure the "Enabled?" box is checked before clicking [ Save ].
    (function(){
     // Enter Widget title then in parenthesis include the access level number
     // One widget:  "Title(#)" // the "#" in parenthesis is the access level number of that widget
     // Two widgets: "Title 1(#), Title 2(#)" // separate the titles with a comma
     // The title must EXACTLY match the widget title before this script will work
     // access level: public = 1, associate = 1.5, member = 2, council = 2.5, officer = 3, super admin = 4

     var widgetAccess = "Voice Chat (2), Contact Info(2), Council Updates(2.5), Officer Updates (3)"

     /* Don't change anything below */
     ,accessIt = function(cb, t, h){
      if (!cb.length) { return; }
      h = h || 1; // no access level = make public
      var access = parseInt("$block[userlevelnumber]".replace(/\s+/,''),10);
      if (access >= h) { cb.show(); }
     }, a = [], j, n = [], t, list = widgetAccess.split(',');
     for ( j=0; j < list.length; j++ ){
      t = list[j].match(/([^(]*)\(([^)]*)/);
      n.push($.trim(t[1])||''); // widget name
      a.push($.trim(t[2])||1); // access level
     }
     $('.gpWidget').each(function(){
      t = $.trim( $(this).find('.ContentBoxTitle,.ContentBoxTitleNoBackground').text() );
      j = $.inArray(t,n);
      if (j < 0 || widgetAccess.indexOf(t) < 0) {
       $(this).show();
      } else {
       accessIt($(this), n[j], a[j]);
      }
     });
    }());
Customizing

Modify the "widgetAccess" varible to add specific widgets that need an access level. Follow this template:
var widgetAccess = "Title1(#), Title2(2)"
  • The "Title" in blue must EXACTLY match the widget title, spaces included.
  • The access level must be wrapped in parenthesis and follow the title.
  • Access Levels are as follows:

    • public = 1
    • associate = 1.5
    • member = 2
    • council = 2.5
    • officer = 3
    • super admin = 4

  • Add more titles by separating each one with a comma
TopBottom

Kaysi (Guild Admin) 1/14/2012 4:47 PM EST : RE: Widget Access Levels

Kaysi
Posts: 445
Fingers of Fury!

Hello!

I have installed the MOD, altered the code. Our Guild Leader only wants the Welcome box to show to public level viewers. When I log off to test the page, the welcome box is viewable for a flash and then it vanishes.

Where did I mess up?

Thank you very much for your time and help!!!!

Site: http://www.platinum.jediportal.com/Guild.aspx?GuildID=417537&TabID=3548025
Miria Signature
"I can heal any flashpoint, quest, or player, but I can't heal stupidity."
TopBottom

Mottie (MVP) 1/14/2012 7:32 PM EST : RE: Widget Access Levels
GuildPortal MVP
Mottie
Posts: 3883
Zomgawsh Poster

Hi Kaysi!

Actually, it looks like you modified your content box custom code, because the "Welcome" is followed by a "&nbsp;", so try this:
var widget_access_levels = "Welcome&nbsp;(1)"
TopBottom

Kaysi (Guild Admin) 1/15/2012 10:48 AM EST : RE: Widget Access Levels

Kaysi
Posts: 445
Fingers of Fury!

Once again you save the day!!

You are the BEST!!!! Thank you!!!

For you <3
Miria Signature
"I can heal any flashpoint, quest, or player, but I can't heal stupidity."
TopBottom

Mottie (MVP) 1/15/2012 3:08 PM EST : RE: Widget Access Levels
GuildPortal MVP
Mottie
Posts: 3883
Zomgawsh Poster

MMM cookies!!!!!

But sadly, I think this mod is broken... there seems to be a problem with using the block code inside of a mod. I've submitted a support ticket so hopefully it will get fixed soon.
TopBottom

Admins Online
There are   members online.
So-and-so has logged on!
%title%
%message%