vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   if conditionals php (https://vborg.vbsupport.ru/showthread.php?t=300347)

CoffeeLovesYou 07-22-2013 01:29 PM

if conditionals php
 
Hi..
I have a question.

When using PHP and global.php, we can use conditionals like:

PHP Code:

<?php
if ($vbulletin->userinfo['usergroupid'] == '6' )
    {
    echo 
"Hello";
             } else {
             echo 
"You do not have permission for this page"; }
    
?>

However..
Is it possible to do this with user fields?
E.g.
PHP Code:

<?php
if ($vbulletin->userfield['field8'] == 'Yes' )
    {
    echo 
"Hello";
             } else {
             echo 
"You do not have permission for this page"; }
    
?>

So basically, if their userfield field8 value is 'Yes', they can see whatever..

kh99 07-22-2013 01:35 PM

That should work, but you'd want to check $vbulletin->userinfo['field8'] (I don't believe there is a userfield array).

Also, if you have existing users and you add a userfield 8, it will have no value for existing users until they edit their profile (even if you set a default value when you create the field).

CoffeeLovesYou 07-22-2013 01:43 PM

Quote:

Originally Posted by kh99 (Post 2434791)
That should work, but you'd want to check $vbulletin->userinfo['field8'] (I don't believe there is a userfield array).

Also, if you have existing users and you add a userfield 8, it will have no value for existing users until they edit their profile (even if you set a default value when you create the field).

Oh, alright, thanks!
And yes, I am aware. I would run a query to set it to 'Yes' for all users and they can go in and set it to No if they'd like to..
Thanks for the help! :)

--------------- Added [DATE]1374508593[/DATE] at [TIME]1374508593[/TIME] ---------------

Hey kh99,
Are you aware of how to get the notification count?
Like, if their notifications are >= 1, show "x Notifications Waiting"
if it's 0, don't show..
Not sure if this is already a conditional. Thanks

Lynne 07-22-2013 04:35 PM

There are the fields pmunread, vmunreadcount, friendrequestcount, socgroupinvitecount, etc that should be available in the $vbulletin->userinfo array (you can see all these fields in the user table).


All times are GMT. The time now is 02:51 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.01019 seconds
  • Memory Usage 1,724KB
  • 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
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)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