Latest topics
» Forumactif Edge - Releases
by Ange Tuteur Tue 03 Sep 2019, 11:49
» GIFActif - Giphy Button for the Editor
by Ange Tuteur Wed 08 May 2019, 17:21
» Forum Closure
by Ange Tuteur Mon 01 Jan 2018, 01:28
» Chit Chat Thread
by Valoish Sun 31 Dec 2017, 19:15
» Font/Text background color.
by Valoish Sun 31 Dec 2017, 19:11
» Forumactif Messenger - Instant Message Application for Forumotion
by Wolfuryo Sun 31 Dec 2017, 18:24
» [GAME] Count to One Million!
by brandon_g Fri 29 Dec 2017, 18:58
» Post Cards
by manikbiradar Wed 20 Dec 2017, 07:50
» [GAME] Countdown from 200,000
by Valoish Wed 13 Dec 2017, 23:22
» GeekPolice Tech Support Forums - GeekPolice.net
by Dr Jay Mon 11 Dec 2017, 19:12
» Asking about some plugin for Forumotion
by Dr Jay Mon 11 Dec 2017, 19:10
» [GAME] What are you thinking right now?
by Van-Helsing Sat 09 Dec 2017, 14:51
» Widget : Similar topics
by ranbac Wed 06 Dec 2017, 18:11
» Change the Background of the Forum and put an image and how to make prefixs?
by Clement Wed 06 Dec 2017, 15:19
» Hello from Western Australia
by SarkZKalie Wed 06 Dec 2017, 05:34
by Ange Tuteur Tue 03 Sep 2019, 11:49
» GIFActif - Giphy Button for the Editor
by Ange Tuteur Wed 08 May 2019, 17:21
» Forum Closure
by Ange Tuteur Mon 01 Jan 2018, 01:28
» Chit Chat Thread
by Valoish Sun 31 Dec 2017, 19:15
» Font/Text background color.
by Valoish Sun 31 Dec 2017, 19:11
» Forumactif Messenger - Instant Message Application for Forumotion
by Wolfuryo Sun 31 Dec 2017, 18:24
» [GAME] Count to One Million!
by brandon_g Fri 29 Dec 2017, 18:58
» Post Cards
by manikbiradar Wed 20 Dec 2017, 07:50
» [GAME] Countdown from 200,000
by Valoish Wed 13 Dec 2017, 23:22
» GeekPolice Tech Support Forums - GeekPolice.net
by Dr Jay Mon 11 Dec 2017, 19:12
» Asking about some plugin for Forumotion
by Dr Jay Mon 11 Dec 2017, 19:10
» [GAME] What are you thinking right now?
by Van-Helsing Sat 09 Dec 2017, 14:51
» Widget : Similar topics
by ranbac Wed 06 Dec 2017, 18:11
» Change the Background of the Forum and put an image and how to make prefixs?
by Clement Wed 06 Dec 2017, 15:19
» Hello from Western Australia
by SarkZKalie Wed 06 Dec 2017, 05:34
Recent Tutorials
Top posting users this month
Top Achievers
Who is online?
In total there are 26 users online :: 0 Registered, 0 Hidden and 26 Guests :: 2 Bots
None
Most users ever online was 515 on Tue 14 Sep 2021, 15:24
None
Most users ever online was 515 on Tue 14 Sep 2021, 15:24
_userdata.usergroup
Page 2 of 2 • Share
Page 2 of 2 • 1, 2
First topic message reminder :
With this plugin, the variable
is now accessible on any forum version (including FAE).
Administration Panel > Modules > HTML & Javascript > Javascript codes management > Create new javascript
Title: _userdata.usergroup
Placement: In all the pages
Code:
Note: This is not optimized for special moderation privileges. It is not secure. If you want a javascript that is, then just leave a comment below.
I think the modifications are pretty self-explanatory. If anyone has an issue, then feel free to leave a reply on this thread.
Group IDs
is the order of group IDs on your forum,
having the highest priority and
having the lowest.
Cache Time
is the amount of minutes your browser will store the usergroup number.
New! Multiple Groups Option
, all usergroups that a user is in will be searched for and stored, as opposed to just the highest usergroup. If you don't care about lower usergroups that a user is in, then leave this as is.
You're probably wondering how this would be useful. With this plugin comes two new functions. One that can return the group(s) that the user is in (depending on what
is set to) and another that can check if the user is in the group(s) passed into the function.
New! returnGroups
New! checkGroups
Let's put these to use. For example, if you are using FAE and wanted to change the background for all Administrator group members when they visit the forum, you would add the following JavaScript:
Since, on any Forumotion forum, the administrator group ID will always be
.
Also, these are some key numbers that you should know if you use this plugin.
When
is:
, the user is not logged in
, the user is not in any group
I hope you guys like it
With this plugin, the variable
|
Installation
Administration Panel > Modules > HTML & Javascript > Javascript codes management > Create new javascript
Title: _userdata.usergroup
Placement: In all the pages
Code:
- Code:
$(function() {
'_userdata.usergroup ️ 2017 Version 5.0';
'Developed by Ace 1';
'All rights reserved';
window.faGroups = {
groupIDs: [1, 2, 3], // list of groupIDs
cacheTime: 30, // time in minutes to store data
multipleGroups: false, // enable to return all groups the user is in
storage: window.localStorage,
user_id: _userdata.session_logged_in ? _userdata.user_id : 0,
setGroup: function() {
var group,
i = 0, j;
if (faGroups.storage && faGroups.user_id > 0) {
if (!faGroups.storage['ug' + faGroups.user_id] || !(faGroups.storage['ug' + faGroups.user_id + '_exp'] > new Date().getTime() - faGroups.cacheTime * 60 * 1000)) {
$.ajax({
url: '/groups',
type: 'get',
async: false,
success: function(d) {
if (faGroups.multipleGroups) group = [];
for (; i < faGroups.groupIDs.length; i++) {
j = $('ul.noList a[href^="/g' + faGroups.groupIDs[i] + '-', d);
if (j[0]) {
if (!faGroups.multipleGroups) {
group = faGroups.groupIDs[i];
i = faGroups.groupIDs.length;
} else {
group.push(faGroups.groupIDs[i]);
}
}
}
faGroups.storage['ug' + faGroups.user_id] = group ? JSON.stringify(group) : group;
faGroups.storage['ug' + faGroups.user_id + '_exp'] = new Date().getTime();
}
});
}
// sets _userdata.usergroup to the user's current group
if (faGroups.storage['ug' + faGroups.user_id] != 'undefined') {
try {
_userdata.usergroup = JSON.parse(faGroups.storage['ug' + faGroups.user_id]);
} catch(e) {
_userdata.usergroup = faGroups.storage['ug' + faGroups.user_id];
}
} else {
_userdata.usergroup = -1; // user not within any group
}
} else {
_userdata.usergroup = 0; // _userdata.session_logged_in == 0
}
},
returnGroups: function() {
if (!_userdata.usergroup) return;
return JSON.parse(faGroups.storage['ug' + faGroups.user_id]);
},
checkGroups: function() {
var groups_to_check = [].slice.apply(arguments),
user_groups,
in_groups;
if (groups_to_check.length < 1 || !_userdata.usergroup) return;
user_groups = _userdata.usergroup;
if (typeof user_groups == 'object') {
// usergroup == array
if (groups_to_check.length > 1) {
// arguments == array
in_groups = user_groups.every(function(val) {
return groups_to_check.indexOf(val) > -1;
});
return in_groups ? true : false;
} else {
// arguments == string
return user_groups.indexOf(groups_to_check[0]) > -1 ? true : false;
}
} else {
// usergroup == string
if (groups_to_check.length > 1) {
// arguments == array
return false;
} else {
// arguments == string
return groups_to_check[0] == user_groups ? true : false;
}
}
}
};
faGroups.setGroup();
/*** Progress
var logs = {
'Version 1.0': 'Developed',
'Version 2.0': 'Enabled values -1 and 0 (no groups and not logged in, respectively)',
'Version 3.0': 'Enhanced and simplified',
'Version 4.0': 'Enabled multipleGroups, returnGroups(), checkGroups(args)'
'Version 5.0': 'Patched unexpected tokens in JSON as well as errors when _userdata.session_logged_in == 0'
};
***/
});
Note: This is not optimized for special moderation privileges. It is not secure. If you want a javascript that is, then just leave a comment below.
Modifications
I think the modifications are pretty self-explanatory. If anyone has an issue, then feel free to leave a reply on this thread.
Group IDs
- Code:
groupIDs: [ 1, 2, 3 ],
|
|
|
Cache Time
- Code:
cacheTime: 30,
|
New! Multiple Groups Option
- Code:
multipleGroups: false,
|
Use
You're probably wondering how this would be useful. With this plugin comes two new functions. One that can return the group(s) that the user is in (depending on what
|
New! returnGroups
- Code:
faGroups.returnGroups();
// will return a number or an array
New! checkGroups
- Code:
faGroups.checkGroups(1);
faGroups.checkGroups(1, 2, ...);
// will return true or false
Let's put these to use. For example, if you are using FAE and wanted to change the background for all Administrator group members when they visit the forum, you would add the following JavaScript:
- Code:
$(function() {
faGroups.checkGroups(1) && $('#fa_edge').css('background-color', 'black');
});
Since, on any Forumotion forum, the administrator group ID will always be
|
Also, these are some key numbers that you should know if you use this plugin.
When
|
|
|
I hope you guys like it
Last edited by Ace 1 on Fri 06 Oct 2017, 09:53; edited 17 times in total
- STBW
- Gender :
Posts : 33
Points : 3590
Reputation : 2
Language : Spanish
Browser : Forum Version :
Hmmm.. put around 150-200 (If it is not too much >.<) if not I can try to restrict it to users, I am being optimist with the possible amount
Oh damn... That's a lot of groups. To be honest, I'm surprised the code above hasn't already made things unpleasant for the members of your forum. I mean, I feel bad telling you that getting what you want to be difficult. The script iterates through all the group URLs (and all the pages within each) to find the currently logged on user. It stops at the first one; this saves a lot of time. If I were to make it loop through ALL groups EVERY time it could put strain on your browser.
Maybe some time in the future Forumotion could add usergroup as a default to the _userdata object (but even then, doing your task could be really detrimental to end-users' experiences).
Maybe some time in the future Forumotion could add usergroup as a default to the _userdata object (but even then, doing your task could be really detrimental to end-users' experiences).
- STBW
- Gender :
Posts : 33
Points : 3590
Reputation : 2
Language : Spanish
Browser : Forum Version :
Haha! Alright, I see what do you mean.
And.. what if we make the code to work just for 20 specific groups? So if a user is on more of one of those 20 specific groups the functions associed to those groups work at same time. There is any possibility of that?
Ty for your time
EDITED: Forgotten to mention you @Ace 1
And.. what if we make the code to work just for 20 specific groups? So if a user is on more of one of those 20 specific groups the functions associed to those groups work at same time. There is any possibility of that?
Ty for your time
EDITED: Forgotten to mention you @Ace 1
Well, it's been a while but I looked back over this when trying to decrease loading time on my forum and I decided that like always my methods were extremely convoluted and could be greatly simplified. So that's precisely what I did. like said topic
Hope there's less lag now.
Hope there's less lag now.
- @STBW:
- dw I haven't forgotten about you I'll be working on a solution rn (should be done in the next 2 days)
Sorry for the double post; I'm just pointing out that I've made a bunch of revisions to the script.
I hope it is used and enjoyed. Especially by @Ange Tuteur
I hope it is used and enjoyed. Especially by @Ange Tuteur
- Sponsored content
Page 2 of 2 • 1, 2
Create an account or log in to leave a reply
You need to be a member in order to leave a reply.
Page 2 of 2
Permissions in this forum:
You cannot reply to topics in this forum