Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Snitz Forums 2000 MOD-Group
 MOD Add-On Forum (W/O Code)
 Controlling access to other pages with usergroup
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Kent
Junior Member

United States
193 Posts

Posted - 27 November 2003 :  10:55:22  Show Profile
I've implemented Nikkol's UserGroup Mod and have it controlling access to the forums the way that I want it, but would like to use it to control access to some other portal pages and specific functions. Has anyone else done this and can provide some insight into how it's done...

I'm only using two usergroups, so that part of it is simple...

What session variable and value can I use to do this? If using one of the new session variables isn't practical, what would you suggest?

tribaliztic
Senior Member

Sweden
1532 Posts

Posted - 23 December 2003 :  12:53:14  Show Profile  Visit tribaliztic's Homepage  Send tribaliztic an ICQ Message
I'm planning on setting something up with this, how did you solve this? Or has anyone else done this?

/Tribaliztic
- www.gotlandrace.se -
Go to Top of Page

Kent
Junior Member

United States
193 Posts

Posted - 24 December 2003 :  10:55:57  Show Profile
I couldn't get the session variable to work. So, I set a new variable in inc_header.asp, then used the new function in inc_function_common.asp to set that variable. I restricted whole pages with a simple include that checks that variable and redirects to an "error page." I also used that variable to hide/show functions in the interface, like the ability to attach files to posts, etc.

All this is to restrict access to most portions of my portal to "dues-paying club members" while allowing registered users to still access some portions. Lurkers can browse selected areas but not post, registered users can post in a couple of forums, plus place classified ads. Dues-paying members can upload pictures, post in all forums, access the "resources section" with links, articles, etc.

You can see how I have the different levels/restrictions set up on this page:

http://www.simpletractors.com/club2/membership_benefits.asp

I've just finished integrating PayPal payments, plus some custom "accounting stuff" so that club members can mail in dues payments. The PayPal payment automatically changes their UserGroup to give them full access, while the club treasurer can record checks/money orders, which then updates their UserGroup to provide access.

This is all new -- just implemented the payments stuff yesterday, and the restrictions go into effect 1/15/04....

Edited by - Kent on 24 December 2003 11:03:49
Go to Top of Page

tribaliztic
Senior Member

Sweden
1532 Posts

Posted - 28 December 2003 :  17:01:24  Show Profile  Visit tribaliztic's Homepage  Send tribaliztic an ICQ Message
Ooh.. really like your forum =)
Could you post the codes for that functions and variables and so on? That's exactly what I'm looking for! I "only" need to be able to control access to certain pages and parts of pages...

/Tribaliztic
- www.gotlandrace.se -

Edited by - tribaliztic on 28 December 2003 17:04:25
Go to Top of Page

Kent
Junior Member

United States
193 Posts

Posted - 29 December 2003 :  11:16:22  Show Profile
Here's a basic overview, you'll need to modify it to your needs. The UserGroup_ID for the two categories of users are Paid Member = 5 and Registered User = 2. I have newly registered users automatically added to the Registered User group. When they pay their dues (i.e. subscribe) then their UserGroup_ID is changed to 5.

Here's the code in the inc_header.asp page that I added, just at the end of the Usergroup_Mod code:
'#######    Begin UserGroup MOD     #######
if Session(strCookieURL & "UserGroups" & MemberID) = "" or _
	IsNull(Session(strCookieURL & "UserGroups" & MemberID)) then
	strGroupMembership = getGroupMembership(MemberID,1)
	Session(strCookieURL & "UserGroups" & MemberID) = strGroupMembership
	Session(strCookieURL & "UserGroups" & MemberID) = strGroupMembership
end if
' ##### Added by Kent to implement UserGroup control of portal pages
Dim UsrGp
UsrGp = 2
Dim tUsrGp 
tUsrGp = getGroupMembership(MemberID,1)
If MLev = 0 Then
    UsrGp = 0
  ElseIf InStr(tUsrGp,5) <> 0 Then 
    UsrGp = 5
  Else UsrGp = 2
End If 
'#######     End UserGroup MOD      #######

Note that I set the UsrGp variable to 0 if MLev = 0, so that I can use one variable to control access to things (especially menu options).

Here's my readme to help me keep track of the changes I've made:

http://www.simpletractors.com/club34/readme_restricted_pages.htm

Here's the code of the simple include file that I use to control access.
<% 
'###### Kent's Code -- see readme_restriced_pages.htm for details #####
If UsrGp <> 5 Then
   response.redirect "members_only.asp"
End If
%>


Hope this helps. If you have any questions, just post them. I'm not a programmer, but I'll try to help.
Go to Top of Page

tribaliztic
Senior Member

Sweden
1532 Posts

Posted - 29 December 2003 :  19:35:34  Show Profile  Visit tribaliztic's Homepage  Send tribaliztic an ICQ Message
Okay, that doesn't seem that hard to implement when you have done all the dirty-work =)
I'm needing more than two different groups though..
Would the code look something like this then or is there another way? =)

' ##### Added by Kent to implement UserGroup control of portal pages
Dim UsrGp
UsrGp = 2
Dim tUsrGp
tUsrGp = getGroupMembership(MemberID,1)
If MLev = 0 Then
UsrGp = 0
ElseIf InStr(tUsrGp,5) = 1 Then
UsrGp = 1
ElseIf InStr(tUsrGp,5) = 2 Then
UsrGp = 2
ElseIf InStr(tUsrGp,5) = 3 Then
UsrGp = 3
End If


/Tribaliztic
- www.gotlandrace.se -
Go to Top of Page

DavidRhodes
Senior Member

United Kingdom
1222 Posts

Posted - 29 December 2003 :  20:53:03  Show Profile
looks good, I was planning to do this but probably not going to now because I have several bugs in the UserGroups mod, is membership_benefits.asp a static page though

The UK MkIVs Forum
Go to Top of Page

Kent
Junior Member

United States
193 Posts

Posted - 30 December 2003 :  00:35:23  Show Profile
quote:
Originally posted by DavidRhodes

looks good, I was planning to do this but probably not going to now because I have several bugs in the UserGroups mod, is membership_benefits.asp a static page though


Yes, the membership_benefits.asp page is static...

I'm not a programmer, so this whole thing is a hack job...

That says a lot for HuwR's base code, though I've added several mods on top of it...

Edited by - Kent on 30 December 2003 00:36:06
Go to Top of Page

Kent
Junior Member

United States
193 Posts

Posted - 30 December 2003 :  00:55:43  Show Profile
quote:
Originally posted by tribaliztic

Okay, that doesn't seem that hard to implement when you have done all the dirty-work =)
I'm needing more than two different groups though..
Would the code look something like this then or is there another way? =)

' ##### Added by Kent to implement UserGroup control of portal pages
Dim UsrGp
UsrGp = 2
Dim tUsrGp
tUsrGp = getGroupMembership(MemberID,1)
If MLev = 0 Then
UsrGp = 0
ElseIf InStr(tUsrGp,5) = 1 Then
UsrGp = 1
ElseIf InStr(tUsrGp,5) = 2 Then
UsrGp = 2
ElseIf InStr(tUsrGp,5) = 3 Then
UsrGp = 3
End If





Not quite. The function getGroupMembership(MemberID,1) returns a comma-delimited string that can include more than one UserGroup_ID. For example if you have your forums set up to automatically add them to UserGroup_ID 1 when they join, and then you add them to UserGroup_ID 3, the getGroupMembership function will return the value of 1,3

Also, the "in-string" function, InStr, looks in that string (tUsrGp)for the value of UserGroup_ID that you specify as the parameter in InStr(stringname,value). In my example I'm looking for a value of 5. So, you'd want to be looking for a value of 1, 2, or 3 in the tUsrGp string. It returns a value of True (1) or False (0).

Also, since I programmatically change my UserGroup_ID of 2 to 5 when they pay, I don't have to worry about all the possible combinations. It's an either/or, though I still used the InStr function just in case I have to manually (using Admin_UserGroups.asp) give someone credit for paying their dues, and they end up being a member of both.

If you plan to let them be members of more than one UserGroup, you'd need to set it up where the most restrictive usergroup was the one that you check last, and the least restrictive group was the one you check first. Since any occurance of the UserGroup_ID in the string would change the value that you're setting for UsrGp variable.

You'd want to use something like:

If InStr(tUsrGp,1) <> 0 Then
UsrGp = 1
EndIF
If InStr(tUsrGp,2) <> 0 Then
UsrGp = 2
EndIf
If InStr(tUsrGp,3) <> 0 Then
UsrGp = 3
EndIF

Does that make sense? I'm sure that there are easier ways to do this, but I think that would work...

Edited by - Kent on 30 December 2003 10:51:38
Go to Top of Page

tribaliztic
Senior Member

Sweden
1532 Posts

Posted - 02 January 2004 :  04:30:40  Show Profile  Visit tribaliztic's Homepage  Send tribaliztic an ICQ Message
Hmm.. I don't think I'm skilled enough do make this work =)
I'll probably just copy the M_LEV-code and make like a M_GROUP or something with the same function as the M_LEV. It will work I think =)

/Tribaliztic
- www.gotlandrace.se -
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.31 seconds. Powered By: Snitz Forums 2000 Version 3.4.07