vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Variable for userid (https://vborg.vbsupport.ru/showthread.php?t=211037)

EagleNick 04-12-2009 09:49 PM

Variable for userid
 
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

Quote:

Originally Posted by EagleNick (Post 1789834)
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

Code:

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:

Code:

$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.

Code:

$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

Quote:

Originally Posted by EagleNick (Post 1789902)
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

Quote:

Originally Posted by EnIgMa1234 (Post 1789904)
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

Quote:

Originally Posted by EagleNick (Post 1789911)
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:

Code:

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

Also try adding the following the the function as well:
Code:

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

Code:

$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

Quote:

Originally Posted by EagleNick (Post 1789925)
Success!!!!

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

No problem :)


All times are GMT. The time now is 02:38 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.01191 seconds
  • Memory Usage 1,758KB
  • 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
  • (6)bbcode_code_printable
  • (5)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (14)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