![]() |
RE-DIRECTING TO REGISTER Based on Permissions
Hi;
I have created custom pages that I only want subscribed (paying) members to be able to view. If an unregistered/registered member (who has not paid) tries to view, I have created a re-direct with the following code: Code:
// Permissions Redirect User Group 2 = Registered; User Group 3 = Awaiting Email; User Group 4 = In Moderation; However, the page is not redirecting properly. What am I doing wrong in my coding? Any help would be very much appreciated, Jack --------------- Added [DATE]1428650994[/DATE] at [TIME]1428650994[/TIME] --------------- Someone PM'd me this coding, and it works, but unfortunately it directs every user group to register: Code:
if (!$vbulletin->userinfo['userid'] AND THIS_SCRIPT != 'register') Would appreciate some help :) |
If you have a usergroupid and you want to check it, you could do this:
Code:
if (in_array($usergroupid, array(1, 2, 3, 4))) Or to check the current user you could do this: Code:
if (is_member_of($vbulletin->userinfo, 1, 2, 3, 4)) Of course you could also use !is_member_of and only list the usergorups that should have access, if that's easier. |
Thank you very much.
How does it know to redirect the user to register.php? --------------- Added [DATE]1428679328[/DATE] at [TIME]1428679328[/TIME] --------------- Could you elaborate on do redirect? --------------- Added [DATE]1428679709[/DATE] at [TIME]1428679709[/TIME] --------------- Quote:
Thank you! |
The "do redirect" comment is meant to show where you'd put the code you posted at the end of post #1.
|
You mean this?
Code:
if (is_member_of($vbulletin->userinfo, 1, 2, 3, 4)) |
Where are you putting that code exactly? It would only work if your custom pages include vbulletin's global.php, and that redirect code would have to be after global.php was included.
|
I have a custom vBB page, and here is where I am trying to insert the code:
Code:
<?php I think it might be easier to just list the user groups that can access the page. What would the code be for that? |
Well, first we need to figure out why it's not working right. You said before that this code did the redirect but for everyone?
Code:
if (!$vbulletin->userinfo['userid'] AND THIS_SCRIPT != 'register') And what I suggested didn't redirect anyone? |
I think I have it figured out. The following seems to work:
Code:
// Permissions Redirect Thank you for your time! Jack --------------- Added [DATE]1428686841[/DATE] at [TIME]1428686841[/TIME] --------------- PS: I would be interested to see your code where only members X, Y could have access ... with all others getting a No Permissions message. |
All times are GMT. The time now is 07:02 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|