Log in

View Full Version : Variable for userid


EagleNick
04-12-2009, 09:49 PM
I have created plugin for the member_build_blocks_start hook and I need to use the UserID variable. I've tried a slew of things such as:
$user['userid']
$prepared[userid]
$bbuserinfo[userid]

And none of them work.

What is the proper variable to use?

Thanks.

EnIgMa1234
04-12-2009, 10:12 PM
I have created plugin for the member_build_blocks_start hook and I need to use the UserID variable. I've tried a slew of things such as:
$user['userid']
$prepared[userid]
$bbuserinfo[userid]

And none of them work.

What is the proper variable to use?

Thanks.
$prepared['userid']

You were missing the ' '

EagleNick
04-12-2009, 10:50 PM
For some reason, it's not working. Whenever I use that variable, the entire plugin just stops working.

I know for sure that it's this variable causing the problem because when I change it to something else or remove it, it works fine.

I thought maybe I need to escape the single-quotes so I inserted backslashes before each one ($prepared[\'userid\']). The plugin worked when I did this, but the variable didn't parse. I simply gave "$prepared[\'userid\']" as the output.

I don't know what the problem is.

EnIgMa1234
04-12-2009, 11:35 PM
I'm using it in a query like this

WHERE userid = '".$prepared['userid']."'

If that doesn't work you can also try $userinfo['userid']

EagleNick
04-13-2009, 12:23 AM
I'm not using it in a query; I'm using it in a plugin. I'm not sure if it makes a difference though... :confused:

--------------- Added 12 Apr 2009 at 21:26 ---------------

Okay, that isn't working either. Here's my plugin:

$blocklist = array_merge($blocklist, array(
'licenses' => array(
'class' => 'licenses',
'title' => 'User Licenses',
'hook_location' => 'profile_left_last'
)
));

class vB_ProfileBlock_licenses extends vB_ProfileBlock
{
var $template_name = 'memberinfo_block_licenses';

function confirm_empty_wrap()
{
return false;
}

function confirm_display()
{
return ($this->block_data['licenses'] != '');
}

function prepare_output($id = '', $options = array())
{
$this->block_data['licenses'] = '<iframe src="http://www.mydomain.net/admincp/vbma_admin.php?do=viewuserslicenses&userid=userIDhere" width="100%"></iframe>';
}
}What I'm doing is adding a new tab to the user profiles. Basically, the content of the tab will be an iframe of a page in the AdminCP (code in blue). I need the code in red to become the user ID of the person's profile I'm viewing.

So now here is the list of things I've tried (in place of the red code):

$user['userid']
$prepared[userid]
$prepared['userid']
'".$prepared['userid']."'

... and none of them work.

EnIgMa1234
04-13-2009, 12:33 AM
Try this.

$blocklist = array_merge($blocklist, array(
'licenses' => array(
'class' => 'licenses',
'title' => 'User Licenses',
'hook_location' => 'profile_left_last'
)
));

class vB_ProfileBlock_licenses extends vB_ProfileBlock
{
var $template_name = 'memberinfo_block_licenses';

function confirm_empty_wrap()
{
return false;
}

function confirm_display()
{
return ($this->block_data['licenses'] != '');
}

function prepare_output($id = '', $options = array())
{
$outdata = "<iframe src=\"http://www.mydomain.net/admincp/vbma_admin.php?do=viewuserslicenses&userid=\".$prepared['userid']."\" width=\"100%\"></iframe>";
$this->block_data['licenses'] = $outdata;
}
}

EagleNick
04-13-2009, 12:37 AM
Nope, no dice. Have no clue what the problem is :(
The tab doesn't even appear with this code.

EnIgMa1234
04-13-2009, 12:42 AM
Nope, no dice. Have no clue what the problem is :(
The tab doesn't even appear with this code.
Does the iframe page exist or did you change the URL in my code? The tab won't display if theres no data assigned to the variable.

EagleNick
04-13-2009, 12:50 AM
Does the iframe page exist or did you change the URL in my code? The tab won't display if theres no data assigned to the variable.
I changed the URL from mydomain to what my actual domain is. And yes, the iFrame page exists, provided the userID is parsed correctly.
In other words, if I place nothing after userid=, it works. If I put a number in there such as '1', it works. Apparently, we haven't found the right variable for the userId.

EnIgMa1234
04-13-2009, 01:09 AM
I changed the URL from mydomain to what my actual domain is. And yes, the iFrame page exists, provided the userID is parsed correctly.
In other words, if I place nothing after userid=, it works. If I put a number in there such as '1', it works. Apparently, we haven't found the right variable for the userId.
Try assigning what you are using to a new variable like:

$usersid = $prepared['userid'];
in the prepare_output function and use $usersid variable instead.

Also try adding the following the the function as well:
global $vbulletin, $prepare;

EagleNick
04-13-2009, 01:11 AM
I'm not sure what you mean... :confused: Where do I place those?

Please forgive my ignorance in this field.

EnIgMa1234
04-13-2009, 01:20 AM
$blocklist = array_merge($blocklist, array(
'licenses' => array(
'class' => 'licenses',
'title' => 'User Licenses',
'hook_location' => 'profile_left_last'
)
));

class vB_ProfileBlock_licenses extends vB_ProfileBlock
{
var $template_name = 'memberinfo_block_licenses';

function confirm_empty_wrap()
{
return false;
}

function confirm_display()
{
return ($this->block_data['licenses'] != '');
}

function prepare_output($id = '', $options = array())
{
global $vbulletin, $prepared;
$usersid = $prepared['userid'];
$outdata = "<iframe src=\"/admincp/vbma_admin.php?do=viewuserslicenses&userid=$usersid\" width=\"100%\"></iframe>";
$this->block_data['licenses'] = $outdata;
}
}
Try that. Don't forget to replace your sitename.

EagleNick
04-13-2009, 01:25 AM
Success!!!!

Thank you SO VERY MUCH. I really appreciate it. :cool:

EnIgMa1234
04-13-2009, 01:26 AM
Success!!!!

Thank you SO VERY MUCH. I really appreciate it. :cool:
No problem :)