The Arcive of vBulletin Modifications Site. |
|
|
#1
|
|||
|
|||
|
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
if ($usergroupid==8) {
header("Location: $url_register");
} else if ($usergroupid <= 1) {
header("Location: $url_register");
} else if ($usergroupid <= 2) {
header("Location: $url_payments");
} else if ($usergroupid <= 3) {
header("Location: $url_payments");
} else if ($usergroupid <= 4) {
header("Location: $url_payments");
}
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')
{
header("Location: " . $vbulletin->options['bburl'] . "/register.php");
}
Would appreciate some help
|
|
#2
|
|||
|
|||
|
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)))
{
// do redirect
}
Or to check the current user you could do this: Code:
if (is_member_of($vbulletin->userinfo, 1, 2, 3, 4))
{
// do redirect
}
Of course you could also use !is_member_of and only list the usergorups that should have access, if that's easier. |
|
#3
|
|||
|
|||
|
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! |
|
#4
|
|||
|
|||
|
The "do redirect" comment is meant to show where you'd put the code you posted at the end of post #1.
|
|
#5
|
|||
|
|||
|
You mean this?
Code:
if (is_member_of($vbulletin->userinfo, 1, 2, 3, 4))
{
header("Location: " . $vbulletin->options['bburl'] . "/register.php");
}
|
|
#6
|
|||
|
|||
|
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.
|
|
#7
|
|||
|
|||
|
I have a custom vBB page, and here is where I am trying to insert the code:
Code:
<?php
// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
// #################### DEFINE IMPORTANT CONSTANTS #######################
define('THIS_SCRIPT', 'srcImages');
define('CSRF_PROTECTION', true);
// change this depending on your filename
// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array();
// get special data templates from the datastore
$specialtemplates = array();
// pre-cache templates used by all actions
$globaltemplates = array('IMAGE_HOSTING',
);
// pre-cache templates used by specific actions
$actiontemplates = array();
// ######################### REQUIRE BACK-END ############################
// if your page is outside of your normal vb forums directory, you should change directories by uncommenting the next line
// chdir ('/path/to/your/forums');
require_once('./global.php');
$navbits = construct_navbits(array('' => 'Image Hosting'));
$navbar = render_navbar_template($navbits);
// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################
if (is_member_of($vbulletin->userinfo, 1, 2, 3, 4))
{
header("Location: " . $vbulletin->options['bburl'] . "/register.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? |
|
#8
|
|||
|
|||
|
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')
{
header("Location: " . $vbulletin->options['bburl'] . "/register.php");
}
And what I suggested didn't redirect anyone? |
|
#9
|
|||
|
|||
|
I think I have it figured out. The following seems to work:
Code:
// Permissions Redirect
if ($usergroupid==8) {
header("Location: $url_/register.php");
} else if ($usergroupid <= 1) {
header("Location: $url_/register.php");
} else if ($usergroupid <= 2) {
header("Location: $url_/payments.php");
} else if ($usergroupid <= 3) {
header("Location: $url_/payments.php");
} else if ($usergroupid <= 4) {
header("Location: $url_/payments.php");
}
![]() 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. |
![]() |
|
|
| X vBulletin 3.8.12 by vBS Debug Information | |
|---|---|
|
|
More Information |
|
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|