vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Using private profile field in conditionals (https://vborg.vbsupport.ru/showthread.php?t=82665)

makaiguy 06-08-2005 03:14 AM

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?

Adrian Schneider 06-08-2005 03:30 AM

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.

makaiguy 06-09-2005 04:34 AM

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.

Princeton 06-09-2005 12:20 PM

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.

Adrian Schneider 06-09-2005 01:38 PM

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.

makaiguy 06-09-2005 06:34 PM

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 .... ?

makaiguy 06-14-2005 01:19 AM

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?

Adrian Schneider 06-14-2005 03:32 AM

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.

makaiguy 06-14-2005 08:09 PM

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

It's installed and working great.

makaiguy 06-23-2005 05:48 PM

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"?


All times are GMT. The time now is 05:56 AM.

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.01963 seconds
  • Memory Usage 1,749KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_php_printable
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete