View Full Version : Help requested: Auto entry into usergroup from fieldX profile entry
makaiguy
04-18-2005, 01:19 AM
[Edited to simplify request]
I've searched but not found anything similar. Maybe I just wasn't creative enough in my search terms.
I would like to restrict entry to a given forum to those that have a particular value entered in a custom field in their profiles. I've created the field in the profile and also added a new vBphrase in which I can store the required value.
Would appreciate any guidance on how to accomplish this. I see two possibilities: Each time the user enters the board, his fieldx value is compared to the reference vBphrase value, and if they match, he is automatically put into a special usergroup created for the purpose. If the fieldx value doesn't match the reference value, he is not put in/removed from the special usergroup. Then I can just use standard usergroup permissions to allow entry to the forum. Some custom code entered into the section that grants forum access. Pseudocode would look something likeif [(requesting specified conference number)
and (fieldx doesn't match required value)]
then (deny access)
end if
Method "a" would be preferable because there may be some other permissions that could be added later and easily managed by this usergroup, but if method "b" is all anyone can help with, I'll gratefully take that too.
Any suggestions on how to do this?
makaiguy
04-21-2005, 11:37 PM
Since I've received no responses in 4 days, I've revised my post to make it clearer and more concise. Anybody got any ideas?
Marco van Herwaarden
04-22-2005, 03:25 AM
Is there any reason this must be based on a field in the profile, instead of just using Public Joinable Usergroup?
makaiguy
04-22-2005, 04:51 AM
Is there any reason this must be based on a field in the profile, instead of just using Public Joinable Usergroup?
Heh heh. Now we're getting into the stuff I edited out of the original post to make it more concise ...
The bbs is an adjunct to an organization's existing website. People who have paid to join the organization receive a username and password that gets them into the members-only portions of the site. The password is changed periodically for security reasons.
I already do a comparison with the custom profile field value against a reference phrase set to the current org pwd and display their member status in postbits. When the organization password is updated, I just change the reference phrase value and folks aren't shown as members again until they update their profiles with the updated org. pwd.
The forum in question is to be reserved for organization members only. I've initially set this forum up to require a password, which I've set to the organization password. When the organization password is updated, we just update the forum password. This works, but I'd like to automate it so that organization members wouldn't have to enter the password every time they enter this forum.
Further, I'd like for the members to have to update the organization password in their profiles each time it's updated by the organization to weed out people that have not renewed their organization membership.
The organization is large enough that I don't want bbs staff to have to manually approve entry into a user group, For one thing the bbs staff does not have access to the organization's membership records, plus I don't want the members to have to wait for somebody to react to their request every time the org pwd is updated.
Maybe there's some other way to go about this that I haven't thought of (I'm very new to vB except as a user).
I've not yet looked into promotions. Could promotions somehow be used for this?
i.e. automatically promote users from Registered to Org_Member when they have the required value in fieldx?
if so, does this ratchet them permanently, or would they be demoted out of Org_Member when they no longer have the correct value in fieldx?
Marco van Herwaarden
04-22-2005, 02:45 PM
If you have access from php to organisation records in some way, so you can validate board members (mail address or some other value) then this could be automated yes.
A bit hte same as we are doing here to make a difference between licensed and unlicensed members.
makaiguy
04-22-2005, 06:29 PM
If you have access from php to organisation records in some way, so you can validate board members (mail address or some other value) then this could be automated yes.
A bit hte same as we are doing here to make a difference between licensed and unlicensed members.
No, I'm afraid we don't have access to the organization membership records, which is why we're trying to "come in the back door" via the org password in the user profile.
Marco van Herwaarden
04-22-2005, 07:26 PM
Well if you can not do some matching against the organization database, then a password stored in the userprofile would be one of the less bad options. But i would try to investigate if there really is no way of integration.
makaiguy
04-22-2005, 08:07 PM
Well if you can not do some matching against the organization database, then a password stored in the userprofile would be one of the less bad options. But i would try to investigate if there really is no way of integration.
This may be possible, eventually. I'm not sure what they are using for user records now, but they are just starting to talk about migrating to a database on the same server host as the bbs. And at the rate at which things seem to be done, I don't want to wait for it.
So now that we've decided a field in the profile is at least a half-way reasonable approach for now (all the thought processes I've gone thru before posting in the first place) does anybody have any ideas how to pull it off?
Marco van Herwaarden
04-22-2005, 08:10 PM
Would not be to difficult:
- Create user profile field
- Hack all places where a forum password is checked to match against the field stored in profile
- 1 query to reset all passes when changed (not even needed)
But how often does the organisations membership info change? Could you do with a text file that is once a day downloaded to your server?
joeychgo
04-22-2005, 11:18 PM
Why not just add to the profile field, an option for the user to choose this?
makaiguy
04-23-2005, 12:47 AM
Would not be to difficult:
- Create user profile field
- Hack all places where a forum password is checked to match against the field stored in profile
- 1 query to reset all passes when changed (not even needed)
But how often does the organisations membership info change? Could you do with a text file that is once a day downloaded to your server?
Marco - thanks for sticking with me on this.
The org pwd is changed no more than twice a year. So it's not that big a deal for me to manually change the reference string I've stored in a global vBphrase when the pwd changes.
No need to run a query to update the pwds in user profiles when organization updates its pwd - the whole idea is to make the user update his own profile to prove he's a renewing member that has received the password independently.
I found the following code in forumdisplay.php:
// ############################### start enter password ###############################
if ($_REQUEST['do'] == 'doenterpwd')
{
globalize($_REQUEST, array('forumid' => INT, 'newforumpwd' => STR, 'url' => STR, 'postvars'));
$foruminfo = verify_id('forum', $forumid, 1, 1);
if ($foruminfo['password'] == $newforumpwd)
{
...
Now I know about enough php to fill a thimble around 5%, but this looks to be the area we'd need to hack. I'd want to bypass the password request popup under the following conditions: forum being requested is number X (and how can I find the forum number? or can this check be done via forum title? [Edit: by examining the html for the password request page, it looks like my forum is number 3]), AND the user's fieldX == $vBphrase['org_password']... and just manually set $newforumpwd to $foruminfo['password'].
Can anyone help with the required code?
Why not just add to the profile field, an option for the user to choose this?
Thanks, Joey, but I don't understand what you're suggesting. Can you elaborate? An option for the user to choose ... what?
makaiguy
04-26-2005, 03:03 AM
Have tried modifying the code above as follows:
// ############################### start enter password ###############################
if ($_REQUEST['do'] == 'doenterpwd')
{
globalize($_REQUEST, array('forumid' => INT, 'newforumpwd' => STR, 'url' => STR, 'postvars'));
// ################### Check for valid org pwd in profile ##################
// ################### before requesting forum password ##################
// rem out original line: $foruminfo = verify_id('forum', $forumid, 1, 1);
if ($post['field5'] == $vbphrase[org_password])
{
$newforumpwd = $vbphrase[org_password];
}
else
{
$foruminfo = verify_id('forum', $forumid, 1, 1);
}
// ################### END check for valid org pwd in profile ##############
if ($foruminfo['password'] == $newforumpwd)
{
....
Doesn't have the desired effect - with correct org pwd in the custom profile field, it doesn't satisfy the "if" test and proceeds to pop up the forum password request.
I've considered that the "if" test works okay and sets $newforumpwd, my problem might be that $foruminfo doesn't get defined. But looking further down the code, that should trigger an "incorrect password" response rather than showing a forum password request.
My guess is the $post['field5'] or $vbphrase[org_password] variable (or both) is not defined in forumdisplay.php. Both work fine in postbits. I'm guessing $post['field5'] is not the correct way to reference this variable outside of postbits, whereas I defined $vbphrase[org_password] as global.
Of course if I can get the "if" test working, it could be that not getting $foruminfo defined will still jump up and bite me.
Can anyone point me in the right direction?
makaiguy
06-23-2005, 05:49 PM
Have finally found a way to automate putting an individual into a secondary group automatically, based on the value entered in profile fieldX. Now entry into that forum can easily be controlled by normal forum permissions.
For anyone interested in the auto-add code, see https://vborg.vbsupport.ru/showpost.php?p=724840&postcount=9
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.