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
Webpage Group Access
Topic Started: May 9 2011, 07:50 PM (1,931 Views)
Quozzo
Member Avatar
By the blood of Sanguinius!
[ *  *  *  *  * ]
Will redirect anyone to the index if they have not got permission to view the webpage

Place this code at the top of the webpage
Code:
 
<script type='text/javascript'>
//Webpage Group Access by Quozzo
var groupaccess=["Admins","Members"];
$.ajax({url:$('#top_info strong a').attr('href'),async:false,success:function(d){ugroup=$('.user_info dt:contains(Group)',d).next().html();if(!groupaccess.toString().match(ugroup)){location.replace(main_url+"index/")}}});
</script>

Add additional groups into this line in the code above, so if i wanted to add the validating group to view the page, it would look like this:
Code:
 
var groupaccess=["Admins","Members","Validating"];


Edited by Quozzo, Jun 30 2012, 02:34 PM.
Offline Profile Quote Post Goto Top
 
Agent Moose-ZNR
Member Avatar
♪ === ♥
[ *  * ]
This is a nifty code. Nice job :)
Offline Profile Quote Post Goto Top
 
Cory
Member Avatar
Member
[ *  *  *  *  *  *  *  *  * ]
I'm glad you decided to post it, a lot of people have been looking for this.
Online Profile Quote Post Goto Top
 
Quozzo
Member Avatar
By the blood of Sanguinius!
[ *  *  *  *  * ]
I thought it would be a one-off thing but seems quite popular, I decided to post this new one as the old one uses an AJAX requests to go to the Members page which doesn't work anymore and a few people may be asking for a fix. This gets the group by going to the Profile page, i don't know why i didn't do that in the first place tbh :doh:
Offline Profile Quote Post Goto Top
 
Viral
Member Avatar
Viral
[ *  *  *  *  *  * ]
Looks good, but maybe a location.replace() would be better so the back button functions properly.
Edited by Viral, May 10 2011, 08:29 PM.
Offline Profile Quote Post Goto Top
 
Quozzo
Member Avatar
By the blood of Sanguinius!
[ *  *  *  *  * ]
I didn't know about that, thanks.
Offline Profile Quote Post Goto Top
 
Ithuar
Member Avatar
Member
[ * ]
Thanks for the help, Quozzo.
Offline Profile Quote Post Goto Top
 
lonewolfe2015
Member Avatar
Member
[ *  * ]
Was testing this code to see if it could be used to block unregistered people from viewing member lists and webpages, but it caused an endless loop of page refreshes as both an administrator and a guest account. Had to log directly into the ACP (remained logged in) and remove it in order for the page to return to normal function.
Offline Profile Quote Post Goto Top
 
Quozzo
Member Avatar
By the blood of Sanguinius!
[ *  *  *  *  * ]
lonewolfe2015
Jul 7 2012, 05:03 PM
Was testing this code to see if it could be used to block unregistered people from viewing member lists and webpages, but it caused an endless loop of page refreshes as both an administrator and a guest account. Had to log directly into the ACP (remained logged in) and remove it in order for the page to return to normal function.
Thats because its intended use is for webpages
Edited by Quozzo, Jul 7 2012, 05:56 PM.
Offline Profile Quote Post Goto Top
 
lonewolfe2015
Member Avatar
Member
[ *  * ]
Quozzo
Jul 7 2012, 05:56 PM
lonewolfe2015
Jul 7 2012, 05:03 PM
Was testing this code to see if it could be used to block unregistered people from viewing member lists and webpages, but it caused an endless loop of page refreshes as both an administrator and a guest account. Had to log directly into the ACP (remained logged in) and remove it in order for the page to return to normal function.
Thats because its intended use is for webpages
So, if I want to use this, specifically put it into the webpage I'm restricting?

Sorry for any confusion on my end.

Aka, it wouldn't be able to limit access to the member list from guests, for instance.
Edited by lonewolfe2015, Jul 7 2012, 10:58 PM.
Offline Profile Quote Post Goto Top
 
Quozzo
Member Avatar
By the blood of Sanguinius!
[ *  *  *  *  * ]
You can wrap it with some code so it will only work on certain pages
Code:
 
if(/members/.test(location.href)){
//code here
}


you can add additional pages seporated by a bar
Code:
 
if(/members|search/.test(location.href)){
//code here
}


Edited by Quozzo, Jul 7 2012, 11:55 PM.
Offline Profile Quote Post Goto Top
 
lonewolfe2015
Member Avatar
Member
[ *  * ]
Thanks much, placed it at the top of the page and it basically disables access to the members (or other tabs) on command. Very useful for me before the forum I'm making gets opened up outside the admin group.
Offline Profile Quote Post Goto Top
 
Quozzo
Member Avatar
By the blood of Sanguinius!
[ *  *  *  *  * ]
There's an option to disallow everyone bar the admins to view the forum, not sure where it is so your better asking on the support board.
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