PDA

View Full Version : Help with getting this very small plug-in to work with vb 4!


Alien
01-09-2010, 07:08 PM
This used to work beautifully in 3.8.x, but no longer functions in vB 4.0 and I could use some help!

I have gender required at registration, and have the proper profile fields set up with options of Male, Female, and Unknown. Depending on the selection, they can post and reply in the proper forum:

Males can post in the Male forum, but only read in the Female forum.
Females can post in the Female forum, but only read in the Male forum.
Unknown cannot post in either, but can read in both.

Here is the previous code that worked 100%:


if ($foruminfo[forumid] == 34 or $foruminfo[forumid] == 35)
{
// yes, it is
if ($foruminfo[forumid] == 34 and $vbulletin->userinfo[field5] == 'Female')
{
print_no_permission();
}
if ($foruminfo[forumid] == 35 and $vbulletin->userinfo[field5] == 'Male')
{
print_no_permission();
}
if ($vbulletin->userinfo[field5] != 'Male' and $vbulletin->userinfo[field5] != 'Female')
{
print_no_permission();
}
}


Here is the code I've tried with no luck (just results in a White page when trying to make a new thread in the proper place):


if (vB::$vbulletin->foruminfo['forumid'] == 34 or vB::$vbulletin->foruminfo['forumid'] == 35)
{
// yes, it is
if (vB::$vbulletin->foruminfo['forumid'] == 34 and vB::$vbulletin->userinfo['field5'] == 'Female')
{
print_no_permission();
}
if (vB::$vbulletin->foruminfo['forumid'] == 35 and vB::$vbulletin->userinfo['field5'] == 'Male')
{
print_no_permission();
}
if (vB::$vbulletin->userinfo['field5'] != 'Male' and vB::$vbulletin->userinfo['field5'] != 'Female')
{
print_no_permission();
}
}


Can someone help me work this out? Thank you so much!

Lynne
01-09-2010, 07:48 PM
What hook location are you using? Did you try the original plugin at that location since it may have worked as is?

Alien
01-09-2010, 08:27 PM
I used the exact code in these two hook locations:

newreply_start
newthread_start

I did not attempt to use the old code on vBulletin 4.0, I've had it turned off and thought I was forced to update it with the new way variables were done for 4 so I attempted unsuccessfully myself. ;)

Lynne
01-09-2010, 09:06 PM
What hook location did you use it at before? It looks like something you should be using at a forumdisplay_start to me - and it works fine at that location.

Alien
01-09-2010, 09:47 PM
I was always using those hooks I mentioned above with the OLD code, then tried it on the new code with no luck.

I used to insert the code directly into newthread.php and newreply.php before I learned to stick it into the plugin system so I didn't have to edit files on every upgrade. It's so much more convenient.

So if I try it in the forumdisplay_start, I wouldn't have to put it into anywhere else? I'm not trying to prevent people from a forum, I'm preventing the actual POSTING in a forum that does not match their gender? Just wanted to be sure I was clear.

Thank you so much for helping me work through this.

Lynne
01-09-2010, 10:28 PM
Ah, I didn't know you were trying to prevent posting. If you are in a thread though, you probably want to use $threadinfo or $thread instead of $foruminfo. So, try those.

Alien
01-09-2010, 10:39 PM
I shall do that and report back!