Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 06-08-2005, 03:14 AM
makaiguy's Avatar
makaiguy makaiguy is offline
 
Join Date: May 2004
Location: Aiken, SC, USA
Posts: 150
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Using private profile field in conditionals

Background:
Public bbs run by a membership organization. Both org members and non-members use the board. Wish to identify the org members in the author info in postbit.

Using a custom field in profile to identify org members. There is an org password used elsewhere on the site that members enter into this field to verify membership. This field is private so non-members can't see the password in anybody else's profile. Admins are set to be able to see private profile fields.

Have inserted the following code in postbit:
PHP Code:
<if condition="$post['field5'] == $vbphrase[org_password]"><div class="smallfont">Member</div>
<else />
<
div class="smallfont">Guest</div>
</if> 
It works perfectly for admins viewing the thread and the routine correctly identifies who has the right password entered and who doesn't, but non-admins just see everyone shown as Guest.

I suspect this is because only admins have the authority to see private profile fields. When the user for whom the page is being built isn't an admin, I'm guessing the value of field5 isn't being passed to the routine at all, so the match fails and everybody is shown as Guest.

We MUST keep this password field in the profile private so that the org pwd is not shown in the clear, but I need this conditional to work no matter whether the viewer is permitted to view private profile fields or not.

Any suggestions?
Reply With Quote
  #2  
Old 06-08-2005, 03:30 AM
Adrian Schneider's Avatar
Adrian Schneider Adrian Schneider is offline
 
Join Date: Jul 2004
Posts: 2,528
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hmm here is a workaround that might work... Having a field in the user table and have it sync with the profilefield one. You'd just have to change $post['field5'] to $post['newfieldname']. An easy synch would be something like
PHP Code:
if ($bbuserinfo[field5] != $bbuserinfo[newfieldname])
{
    
$updatefields $DB_site->query("
        UPDATE user
        SET newfieldname='
$bbuserinfo[field5]'
        WHERE userid=
$bbuserinfo[userid]
    "
);

in the phpinclude template.
Reply With Quote
  #3  
Old 06-09-2005, 04:34 AM
makaiguy's Avatar
makaiguy makaiguy is offline
 
Join Date: May 2004
Location: Aiken, SC, USA
Posts: 150
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks, I'll give this a try.

Forgive me, but I'm a rank newbie with databases and php (old QuickBasic guy...) so I have a couple of questions:

Would the code above take care of creating that field in the user record, or do I need to do something first to create the new field?

And when/how often would that code be executed by including it in the phpinclude template?

Another approach I thought of was to remove the private classification from field5, but put a conditional in the template that displays the profile, such that it would suppress printing to the screen unless the viewer was that user or an admin. Haven't taken a peek at the code yet to see what that would entail.
Reply With Quote
  #4  
Old 06-09-2005, 12:20 PM
Princeton's Avatar
Princeton Princeton is offline
 
Join Date: Nov 2001
Location: Vineland, NJ
Posts: 6,693
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

members can not view 'private fields' hence why it doesn't work properly for them

why don't you just upgrade the org members into their own USERGROUP?
from there, it would be easier to show their 'membership type'

Quote:
Another approach I thought of was to remove the private classification from field5, but put a conditional in the template that displays the profile, such that it would suppress printing to the screen unless the viewer was that user or an admin. Haven't taken a peek at the code yet to see what that would entail.
this will work - however, I'm not sure how secure the field would be elswhere.
Reply With Quote
  #5  
Old 06-09-2005, 01:38 PM
Adrian Schneider's Avatar
Adrian Schneider Adrian Schneider is offline
 
Join Date: Jul 2004
Posts: 2,528
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by makaiguy
Thanks, I'll give this a try.

Forgive me, but I'm a rank newbie with databases and php (old QuickBasic guy...) so I have a couple of questions:

Would the code above take care of creating that field in the user record, or do I need to do something first to create the new field?

And when/how often would that code be executed by including it in the phpinclude template?
You'd just have to create a field called newfieldname (or use your own, just be consistent) and make the changes. Whenever a user new field and profile field aren't equal, it will update them.
Reply With Quote
  #6  
Old 06-09-2005, 06:34 PM
makaiguy's Avatar
makaiguy makaiguy is offline
 
Join Date: May 2004
Location: Aiken, SC, USA
Posts: 150
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by TheSpecialist
You'd just have to create a field called newfieldname (or use your own, just be consistent) and make the changes. Whenever a user new field and profile field aren't equal, it will update them.
Thanks for trying to help this newbie to vBulletin. But I need you to back up a step or two. HOW do I go about creating the new field in the database? I'm a long time programmer but have never worked with databases. Once the field exists and can be referred to I understand the rest, thanks to your query code.

Quote:
Originally Posted by princeton
members can not view 'private fields' hence why it doesn't work properly for them

why don't you just upgrade the org members into their own USERGROUP?
from there, it would be easier to show their 'membership type'
This would be the ideal solution, but it would have to be done automatically. We're talking literally thousands of members here, with new ones joining and getting the org pwd all the time. And when the pwd changes periodically, they'd all have to automatically drop out of the usergroup until they entered the new pwd into their profiles. (I have no problem updating my vBphrase storing the password manually when the org pwd changes - it doesn't happen all that often.)

But having a special usergroup for org members was what I wanted in the first place as there is SO much you could do with it. See this thread that just sort of died on the vine: https://vborg.vbsupport.ru/showthread.php?t=80089

I'd guess this could be done with a query similar to TheSpecialist's that compares field5 to my org_password phrase then puts that user into or out of the usergroup accordingly. Can anybody help with the query code?

When is the php_include_start code run? When each user logs on, or every time a new page is created, or .... ?
Reply With Quote
  #7  
Old 06-14-2005, 01:19 AM
makaiguy's Avatar
makaiguy makaiguy is offline
 
Join Date: May 2004
Location: Aiken, SC, USA
Posts: 150
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Have found that my host has phymyadmin installed. Have timidly gone in and found the user and userfield tables.

It LOOKS like adding a new field to the user table is as simple as:

Add [1] field at End of Table, and press GO. On next screen, enter field name, type, and other attributes. Haven't had the nerve to press the Save button yet.

Would appreciate it if somebody can confirm the above before I trash my database out of misinterpreting something. Any particular pitfalls a total ignoramus should watch out for?

Also, must I shut the board down or can this be done with the board up?
Reply With Quote
  #8  
Old 06-14-2005, 03:32 AM
Adrian Schneider's Avatar
Adrian Schneider Adrian Schneider is offline
 
Join Date: Jul 2004
Posts: 2,528
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Simple, yes

I'd say VARCHAR 25characters. Depends on your password I guess. The rest should be default, except the name of it, just make sure you are consistent with that.
Reply With Quote
  #9  
Old 06-14-2005, 08:09 PM
makaiguy's Avatar
makaiguy makaiguy is offline
 
Join Date: May 2004
Location: Aiken, SC, USA
Posts: 150
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for the come-back. It's much appreciated.

It's installed and working great.
Reply With Quote
  #10  
Old 06-23-2005, 05:48 PM
makaiguy's Avatar
makaiguy makaiguy is offline
 
Join Date: May 2004
Location: Aiken, SC, USA
Posts: 150
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Have finally found a way to automate putting an individual into a secondary group automatically, based on the value entered in profile fieldX. The above request was just a work-around until I could pull this off.

For anyone interested in the auto-add code, see https://vborg.vbsupport.ru/showpost....40&postcount=9

So now I no longer need that new field we added to the user table, above.

Is getting rid of it as simple as going into phpmyadmin, selecting this field and choosing "Drop"?
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:29 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.07251 seconds
  • Memory Usage 2,262KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_php
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete