PDA

View Full Version : Allow access to a forum based on gender?


Simon Lloyd
10-31-2010, 02:54 PM
Hi all,
I;ve created a custom profile field required on registration (Field 5, single line radio, with options Male, Female) what i would like to do is allow or deny access to a certain form id based on whether they are male or female.

Could someone help with the If conditon? something like:<if condition="$forum[forumid] == X">
AND
<if condition="$vbulletin->userinfo['Field5'] == Male"></if>
SHOW A NO PERMISSON, i think its something like $print_no_permisson<else />
</if> I know this isn't right but it's an idea and i THINK it may go in the forumdisplay template?

Hope you can help :)

JamesC70
10-31-2010, 03:38 PM
Have you considered putting your members into gender-based usergroups?

This way you could use the built-in permissions system (AdminCP -> Forums & Moderators -> Forum Permissions), and Forum Home will automatically display only those forums accessible to that particular member.

This is how most forums restrict access to a moderator area. A side benefit: the permissions system method won't be overridden by a later vBulletin upgrade, as a template update might be.

Simon Lloyd
10-31-2010, 03:59 PM
James thanks for the reply, how can i automatically assign them to gender based groups? the idea of the custom profile field at registration is so they cannot change it later, i have 3 forums Mixed, Guys & Girls so anyone can access mixed but only guys can access guys ....etc

Any suggestions?

--------------- Added 1288548201 at 1288548201 ---------------

I have tried this but no joy!<if condition="($forum[forumid] == 3) AND ($vbulletin->userinfo['Field5'] == Male)"></if>

JamesC70
10-31-2010, 05:10 PM
Ack, my fault. I was thinking the promotions system could handle custom profile fields, and that you could simply tell the system to auto-promote based on field 5. :(

I'm toying with the idea of adding a plugin to fire when the user logs in (login_verify_success, maybe?). The basic thought would be:


if usergroup = registered users
{
get field5
if field5 = "Female"
{
move to usergroup "Female"
}
else
{
move to usergroup "Male"
}
write new usergroup to user record
}

Code idea: https://vborg.vbsupport.ru/showpost.php?p=964406&postcount=53


This idea specifically checks that the member is already in 'Registered Users', so that we don't waste processing time checking banned members, members that have already been moved, or moderators/admins (who presumably would need access regardless of gender).

This method would catch existing members as they log in, and move them appropriately. New registrants could be moved as they confirm their registration using this mod: https://vborg.vbsupport.ru/showthread.php?t=82992

What is your coding experience at adding plugins? Can you take this thought and make it work?

Simon Lloyd
10-31-2010, 05:35 PM
I don't code PHP, im novice to fair on HTML, i've had my main board 2 years and customised it, made tweaks...etc
But that link you gave looks exactly like what i need, so i'll give that a go, thanks very much ;)

JamesC70
10-31-2010, 05:43 PM
Ah, so your experience is about the same as mine. I dabble a little in PHP, but I don't touch the database. ;)

Maybe Lynne or another code expert will see this thread and give some other ideas.....

Simon Lloyd
10-31-2010, 06:39 PM
I added that xml and edited it as needed but it doesn't work so its back to the drawing board, thanks for your help anyway!

BirdOPrey5
10-31-2010, 08:42 PM
A conditional in forumdisplay would work to not display a forum based on gender but there'd be so many ways around this it wouldn't be worth even attempting...

Off hand:
"Last Post" info will still show in forumhome...
User can use "showpost" or even "showthread" manually to view threads and posts, would need to edit each one...
The "Archive" would be unaffected...

The only way to do this right is with usergroup permissions. You could make the male/female group publically joinable so you don't have to do the work manually- but then people could change their sex at any time.

Simon Lloyd
11-01-2010, 08:41 AM
A conditional in forumdisplay would work to not display a forum based on gender but there'd be so many ways around this it wouldn't be worth even attempting...

Off hand:
"Last Post" info will still show in forumhome...
User can use "showpost" or even "showthread" manually to view threads and posts, would need to edit each one...
The "Archive" would be unaffected...

The only way to do this right is with usergroup permissions. You could make the male/female group publically joinable so you don't have to do the work manually- but then people could change their sex at any time.
Thats the problem, i don't want them to be able to change, the custom field is there at registration only and uneditable and hidden after, so i need something like that script that doesn't work to either change them on completion of registration or even after first post because i could force first post to be in say an Introduction forum.

But whatever happens i wouldnt be able to run the site without this moving user based on gender.

BTW im using vB3.8.6

--------------- Added 1288613598 at 1288613598 ---------------

I was trying to re-invent the wheel - this https://vborg.vbsupport.ru/showthread.php?t=186076 works perfectly :), won't be long until i launch the site now :)