PDA

View Full Version : Stuck on php code for the postbit? lol


HMBeaty
09-26-2011, 09:24 PM
Ok, I'm a little confused as to why this isn't working. The code works, however, when I try adding in the option so only certain usergroups can('t) view the content, it doesn't work, nothing shows up. :p

Here's the current code I'm using:
Hook location: postbit_display_start
$noadsense = explode(',', $vbulletin->options['usml_google_adsense_usergroups']);

if ($this->registry->options['usml_google_adsense_enable'] && is_member_of($vbulletin->userinfo, $noadsense))
{
if ($this->registry->options['usml_google_adsense_firstpost'] && $post['isfirstshown'])
{
$template_hook['postbit_end'] .= '
<li class="firstpost_advert_container">
<div class="firstpost_advert">
'.$this->registry->options[usml_google_adsense_firstpostadcode].'
</div>
</li>';
}
}
Obviously it's something silly I'm looking over (again :o), but what is the problem thatis_member_of($vbulletin->userinfo, $noadsense)
doesn't work as it should? :confused:

Boofo
09-26-2011, 10:19 PM
Try:

is_member_of($this->userinfo, $noadsense)


AND

$noadsense = explode(',', $this->registry->options['usml_google_adsense_usergroups']);

HMBeaty
09-26-2011, 10:28 PM
Try:

is_member_of($this->userinfo, $noadsense)
AND

$noadsense = explode(',', $this->registry->options['usml_google_adsense_usergroups']);
Still nothing lol

kh99
09-26-2011, 10:30 PM
Maybe try $this->registry->userinfo.

The list of usergroups in the option is the groups that *will* see the ad, right?

HMBeaty
09-26-2011, 10:33 PM
Maybe try $this->registry->userinfo.

The list of usergroups in the option is the groups that *will* see the ad, right?
That didn't work either lol, and yes (for now anyway).

Boofo
09-26-2011, 10:34 PM
Try using your old code and making $vbulletin global. Did you try using the postbit_display_complete hook instead?

HMBeaty
09-26-2011, 10:40 PM
Try using your old code and making $vbulletin global. Did you try using the postbit_display_complete hook instead?
Ok, did that and now it works :D (still with postbit_display_start). Thanks guys!

Boofo
09-27-2011, 12:43 AM
I was going to suggest making $vbulletin global the first time around but I usually try avoiding doing that in the postbit hooks if at all possible.

HMBeaty
09-27-2011, 12:45 AM
but I usually try avoiding doing that in the postbit hooks if at all possible.
Why is that? Or is that just personal preference?

Boofo
09-27-2011, 12:54 AM
They took out the global $vbulletin for the postbit a while back and I just got used to using to not having to make it global, I guess.

HMBeaty
09-27-2011, 12:58 AM
Ah, ok :)