vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Hooks (https://vborg.vbsupport.ru/showthread.php?t=289469)

Revelence 10-23-2012 12:59 AM

Hooks
 
So I've made a postbit background plugin, which will give certain usergroups a background. It works in my threads, but it's not reading the plugin, or something properly from PM's. I'm guessing it's something with the hook location.

So I'm here to ask what hook location should I use?

My current hook location: postbit_display_start

kh99 10-23-2012 03:18 PM

I think the problem is that $this->post['usergroupid'] is not set if it's a pm (and so you can't use is_member_of(), if that's what you're doing). I don't think there's anything you can do except do a query for it yourself if you're displaying a PM. Maybe something like:

Code:

if (get_class() == 'vB_Postbit_Pm')
{
  $userinfo = fetch_userinfo($this->post['userid']);
}
else
{
  $userinfo &= $this->post;
}

// then use $userinfo to check group...


Revelence 10-23-2012 03:46 PM

Quote:

Originally Posted by kh99 (Post 2375338)
I think the problem is that $this->post['usergroupid'] is not set if it's a pm (and so you can't use is_member_of(), if that's what you're doing). I don't think there's anything you can do except do a query for it yourself if you're displaying a PM. Maybe something like:

Code:

if (get_class() == 'vB_Postbit_Pm')
{
  $userinfo = fetch_userinfo($this->post['userid']);
}
else
{
  $userinfo &= $this->post;
}

// then use $userinfo to check group...


Well that's not really the problem. I use an array to store the usergroup ids, and yes I do use the post['usergroupid']. But if it's not set it wouldn't be in the array, which would just default output it the div without a background.

So I'm still having a feeling it's something with the hooks.

Lynne 10-23-2012 03:56 PM

Are you using debug mode to view the hooks called on each page and have you verified that the hook you are using is being called on the PM page you are looking at?

kh99 10-23-2012 04:13 PM

Quote:

Originally Posted by Revelence (Post 2375344)
But if it's not set it wouldn't be in the array, which would just default output it the div without a background.

So what does happen? Seems like if it's changing the background then the plugin must be running.

Revelence 10-23-2012 04:23 PM

Quote:

Originally Posted by kh99 (Post 2375369)
So what does happen? Seems like if it's changing the background then the plugin must be running.

Okay so I have a plugin say.

Code:

if (1==2)
 //<div class="userinfo" style="background: green;">
else
 //<div class="userinfo">

That's just an example with the if statement, but you should get the picture.

Lynne, that's what I think is wrong. The hook location is wrong and is not being called on the page. How can I turn debug mode on to check which hooks

--------------- Added [DATE]1351013884[/DATE] at [TIME]1351013884[/TIME] ---------------

Okay so I enabled debug mode. postbit_display_start, which is the hook I've been using is enabled in both pages. So I'm still a little confused, I'll try making just something that prints out something to test it.

--------------- Added [DATE]1351013967[/DATE] at [TIME]1351013967[/TIME] ---------------

Nope, I made it output 'Hello', it works in the threads, but still messes up my PM. Weird..

Lynne 10-23-2012 05:42 PM

How about you post the exact php code and hook location so we can try it on our own.

Revelence 10-23-2012 06:02 PM

Plugin hook: postbit_display_start

Code:

Code:

ob_start();
        $usergroupid = $post['usergroupid'];
        $has_bg        = array(6);
        if (in_array($usergroupid, $has_bg)) {
                echo '<div class="userinfo" style="background:url(images/ranks/postbit/'.$usergroupid.'.png);min-height: 350px;">';
        } else {
                echo '<div class="userinfo">';
        }
$php_include = ob_get_contents();
ob_end_clean();
vB_Template::preRegister('postbit_legacy',array('postbit_background' => $php_include));

Then in postbit_legacy template, I replace the
Code:

<div class="userinfo">
with
Code:

{vb:raw postbit_background}

Lynne 10-23-2012 06:23 PM

You can look at the query around line 1611 or private.php and see that the usergroupid is never even grabbed, as Kevin had brought up above. You would need to modify the query to add that in.

Revelence 10-23-2012 06:25 PM

Quote:

Originally Posted by Lynne (Post 2375432)
You can look at the query around line 1611 or private.php and see that the usergroupid is never even grabbed, as Kevin had brought up above. You would need to modify the query to add that in.

No, I'm not worried about that postbit backgrounds actually working with the PM's atm, the problem is, the actual plugin is not being called. If it were being called, it would just show <div class="userinfo">, which it's not.


All times are GMT. The time now is 04:50 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.02205 seconds
  • Memory Usage 1,739KB
  • 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
  • (4)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