Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 01-20-2011, 05:25 PM
MajicPanda MajicPanda is offline
 
Join Date: Jan 2011
Posts: 11
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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.
Reply With Quote
  #2  
Old 01-20-2011, 06:46 PM
Yellow Slider Yellow Slider is offline
 
Join Date: Aug 2006
Posts: 249
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Why don't you just execute your code in the plugin?
Reply With Quote
  #3  
Old 01-24-2011, 06:17 PM
MajicPanda MajicPanda is offline
 
Join Date: Jan 2011
Posts: 11
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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?
Reply With Quote
  #4  
Old 01-24-2011, 07:31 PM
Yellow Slider Yellow Slider is offline
 
Join Date: Aug 2006
Posts: 249
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by MajicPanda View Post
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'].
Reply With Quote
  #5  
Old 01-27-2011, 04:57 PM
MajicPanda MajicPanda is offline
 
Join Date: Jan 2011
Posts: 11
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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)); 
Reply With Quote
  #6  
Old 01-28-2011, 08:20 AM
kesandal kesandal is offline
 
Join Date: Oct 2010
Posts: 36
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Having the same question here...

Does anyone knows an answer?
Reply With Quote
  #7  
Old 01-28-2011, 09:54 AM
Yellow Slider Yellow Slider is offline
 
Join Date: Aug 2006
Posts: 249
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by MajicPanda View Post
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'].
Reply With Quote
  #8  
Old 01-28-2011, 02:28 PM
MajicPanda MajicPanda is offline
 
Join Date: Jan 2011
Posts: 11
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

$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?
Reply With Quote
  #9  
Old 01-29-2011, 03:30 AM
risestar risestar is offline
 
Join Date: Oct 2001
Posts: 31
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

global_start is obsolete in the latest VB4 versions. Use global_bootstrap_init_start instead
Reply With Quote
  #10  
Old 01-30-2011, 08:17 PM
MajicPanda MajicPanda is offline
 
Join Date: Jan 2011
Posts: 11
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by risestar View Post
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.
Reply With Quote
Reply

Thread Tools
Display Modes

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 01:10 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05713 seconds
  • Memory Usage 2,257KB
  • Queries Executed 11 (?)
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
  • (1)bbcode_code
  • (5)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (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_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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete