vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Using VB variables in custom php plugin possible? (https://vborg.vbsupport.ru/showthread.php?t=257483)

MajicPanda 01-20-2011 05:25 PM

Using VB variables in custom php plugin possible?
 
I've got this plugin:

Code:

ob_start();
  include('http://www.va-studios.com/forums/customphp/vigilance.php');
  $vigilance = ob_get_contents();
ob_end_clean();


vB_Template::preRegister('postbit_legacy',array('vigilance' => $vigilance));

I've added a field in my database that I need to access based on the current poster's ID in the postbit_legacy. This code displays right under the users post count on the left.

Is there any way to get the poster's ID in my vigilance.php file so that I can do a db query on it or can I not access VB variables even if I include the global.php file in my script?

Simply stated, I need to do an sql query on the database for the user in the postbit_legacy and display the custom field I added in the database.

Yellow Slider 01-20-2011 06:46 PM

Why don't you just execute your code in the plugin?

MajicPanda 01-24-2011 06:17 PM

I'm still unable to find out how to grab the userID of the poster in my script so that I can grab their custom profile field database entry.

I just need to be able to parse "fieldX" into my script when I execute it.

Any ideas?

Yellow Slider 01-24-2011 07:31 PM

Quote:

Originally Posted by MajicPanda (Post 2153960)
I'm still unable to find out how to grab the userID of the poster in my script so that I can grab their custom profile field database entry.

I just need to be able to parse "fieldX" into my script when I execute it.

Any ideas?

My suggestion is that you just take the code from vigilance.php and put it inside the plugin.
Then you can just use $post['userid'].

MajicPanda 01-27-2011 04:57 PM

How would I do something like this in the plugin, unsure how to get user variables in the plugins.
PHP Code:

$var fieldX//fieldX = custom user profile field
for($i=0$i $var$i++) {
      echo 
"<img src = 'image.jpg'>";


This code gets the logged in users info, but how do you get the posters info related to that postbit section?
PHP Code:

$vigilanceXP $vbulletin->userinfo[field5];

vB_Template::preRegister('postbit_legacy',array('vigilanceXP' => $vigilanceXP)); 


kesandal 01-28-2011 08:20 AM

Having the same question here...

Does anyone knows an answer?

Yellow Slider 01-28-2011 09:54 AM

Quote:

Originally Posted by MajicPanda (Post 2155327)
How would I do something like this in the plugin, unsure how to get user variables in the plugins.
PHP Code:

$var fieldX//fieldX = custom user profile field
for($i=0$i $var$i++) {
      echo 
"<img src = 'image.jpg'>";


This code gets the logged in users info, but how do you get the posters info related to that postbit section?
PHP Code:

$vigilanceXP $vbulletin->userinfo[field5];

vB_Template::preRegister('postbit_legacy',array('vigilanceXP' => $vigilanceXP)); 


$post['field5'].

MajicPanda 01-28-2011 02:28 PM

$post['fieldX'] does not get any data when loading the plugin. I have it in global_start, do I need to be setting this somewhere else or delcaring any includes in the plugin?

risestar 01-29-2011 03:30 AM

global_start is obsolete in the latest VB4 versions. Use global_bootstrap_init_start instead

MajicPanda 01-30-2011 08:17 PM

Quote:

Originally Posted by risestar (Post 2155946)
global_start is obsolete in the latest VB4 versions. Use global_bootstrap_init_start instead

Ok if I set $xpRedOutput to = "test"; then it outputs test, and I know for sure there is data in field8, so why isn't this code snippet resulting in anything being output? All links for images and whanot are correct.

PHP Code:

$xp_num_reds $post[field8];
for(
$i=1$i<=$xp_num_reds$i++) {
    
$xpRedOutput .= "<img src = 'http://www.va-studios.com/images/xpbarred.png'>";
}

vB_Template::preRegister('postbit_legacy',array('xpRedOutput' => $xpRedOutput)); 

<vb:if condition="$post['field8'] == '1'"> in the postbit legacy works fine, but $post['field8'] doesn't work in the plugin.


All times are GMT. The time now is 08:13 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.01091 seconds
  • Memory Usage 1,747KB
  • 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
  • (1)bbcode_code_printable
  • (5)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete