We hope you enjoy your visit.

You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
  • Pages:
  • 1
  • 2
Flexible Form Script Extension: Restrict Groups
Topic Started: Jul 7 2012, 05:46 PM (1,871 Views)
Cory
Member Avatar
Member
[ *  *  *  *  *  *  *  *  * ]
Code Name: Flexible Form Script Extension: Restrict Groups

What the code does: This code works with Reid's Flexible Form Script and will allow you to restrict user groups from sending in applications.

How to use the code: Change Group ID as necessary. The Group ID can be retrieved via the page source (look for 'gid'), or via the member list by selecting a group from the 'Displaying' drop down menu, the &group= number found in the address bar is the Group ID.

How to install the code:

Below the Flexible Form Script code:
Code:
 
<script type="text/javascript">
//<![CDATA[
function dGroup(groupID) {
var group = $.zb.stat.gid;

if (group == groupID) {
form_script.form_id.html('<table cellspacing="0" id="error_box"><thead><tr><th>Error:</th></tr></thead><tbody><tr class="generic"><td>Your user group does not have permission to send in applications</td></tr></tbody></table>');
$('title').text('Error');
}
}

dGroup('GROUP_ID');
//]]>
</script>
Edited by Cory, Dec 13 2013, 12:02 AM.
Offline Profile Quote Post Goto Top
 
Replies:
Cory
Member Avatar
Member
[ *  *  *  *  *  *  *  *  * ]
I have run into this issue so many times and I always forget how 'not equals to' works, being when there is multiple entries, it will cancel out the other entry.

Try this instead:
Code:
 
<!-- Flexible Form Script Extension: Restrict Groups -->
<script type="text/javascript">
//<![CDATA[
function dGroup(groupID) {
if ($.zb.stat.gid === groupID) {
return false;
} else {
form_script.form_id.html('<table cellspacing="0" id="error_box"><thead><tr><th>Error:</th></tr></thead><tbody><tr class="generic"><td>Your user group does not have permission to send in applications.</td></tr></tbody></table>');
$('title').text('Error');
}
}

dGroup('3003425'); // Member
dGroup('3007969'); // Veteran
dGroup('3003422'); // Lord
dGroup('3007974'); // Admin
//]]>
</script>
Offline Profile Quote Post Goto Top
 
mawarm
Member
[ *  * ]
With that code it doesn't seem to work for any group at all, regardless of how many I put there. Any other suggestions?
By the way, with this code if I change it to "!=" instead, all of the groups that I've put there don't work but it does for all others, so it should make sense for it to work with them if it's "===" I suppose...weird.
Edited by mawarm, Dec 7 2016, 01:59 PM.
Offline Profile Quote Post Goto Top
 
Cory
Member Avatar
Member
[ *  *  *  *  *  *  *  *  * ]
This should work:
Code:
 
<!-- Flexible Form Script Extension: Restrict Groups -->
<script type="text/javascript">
//<![CDATA[
$(function() {
var gIDS = [3003425, 3007969, 3003422, 3007974];

if ($.inArray($.zb.stat.gid, gIDS) !== -1) {
return false;
} else {
form_script.form_id.html('<table cellspacing="0" id="error_box"><thead><tr><th>Error:</th></tr></thead><tbody><tr class="generic"><td>Your user group does not have permission to send in applications.</td></tr></tbody></table>');
$('title').text('Error');
}
});
//]]>
</script>
Offline Profile Quote Post Goto Top
 
mawarm
Member
[ *  * ]
Thank you, it's working for all inserted groups now. With this another small problem arose though, the separate error message for guests stopped working. :P
Offline Profile Quote Post Goto Top
 
Cory
Member Avatar
Member
[ *  *  *  *  *  *  *  *  * ]
Try this instead for both codes:
Code:
 
<!-- Flexible Form Script Extension: Restrict Groups -->
<script type="text/javascript">
//<![CDATA[
$(function() {
var gIDS = [3003425, 3007969, 3003422, 3007974];

if ($.inArray($.zb.stat.gid, gIDS) !== -1) {
return false;
} else if ($.zb.logged_in === false) {
form_script.form_id.html('<table cellspacing="0" id="error_box"><thead><tr><th>Error:</th></tr></thead><tbody><tr class="generic"><td>You must be registered and signed in to apply.</td></tr></tbody></table>');
$('title').text('Error');
} else {
form_script.form_id.html('<table cellspacing="0" id="error_box"><thead><tr><th>Error:</th></tr></thead><tbody><tr class="generic"><td>Your user group does not have permission to send in applications.</td></tr></tbody></table>');
$('title').text('Error');
}
});
//]]>
</script>
Offline Profile Quote Post Goto Top
 
mawarm
Member
[ *  * ]
It's all fine and dandy now, thank you very much! :yoda:
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · ZetaBoards Codes & Modifications · Next Topic »
Add Reply
  • Pages:
  • 1
  • 2