PDA

View Full Version : Using VB variables in custom php plugin possible?


MajicPanda
01-20-2011, 05:25 PM
I've got this plugin:

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('v igilance' => $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
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.
$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?

$vigilanceXP = $vbulletin->userinfo[field5];

vB_Template::preRegister('postbit_legacy',array('v igilanceXP' => $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
How would I do something like this in the plugin, unsure how to get user variables in the plugins.
$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?

$vigilanceXP = $vbulletin->userinfo[field5];

vB_Template::preRegister('postbit_legacy',array('v igilanceXP' => $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
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.

$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('x pRedOutput' => $xpRedOutput));

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

MajicPanda
02-02-2011, 11:05 PM
No one has the equivalent of $post[fieldX] that would work in a plug in?

MajicPanda
02-19-2011, 02:57 AM
Still looking for a way to reference a profile field in a php plugin..