PDA

View Full Version : Plugin code to show for specific usergroup only


Gripi
06-14-2013, 07:18 PM
Hello..

how to change this code to work inside the plugin:

show to specific group only:

<if condition="is_member_of($vbulletin->userinfo, 1, 2, 3)"></if>

i already try:

if (is_member_of($vbulletin->userinfo, 1, 2, 3)) {

}

but no luck.

thanks

kh99
06-14-2013, 07:32 PM
That should work. Which hook are you using? You may need to add
global $vbulletin;


to the beginning of your plugin code.

Gripi
06-15-2013, 04:38 AM
Hello.. not working..

i use it in forumhome_complete

kh99
06-15-2013, 07:08 AM
Hmm...I don't see why that wouldn't work, and you don't need a "global" statement there. If you're using it to decide to add something to the FORUMHOME template, are you registering your variable to the template?

Gripi
06-15-2013, 07:33 AM
I installed one mod from vb.org, and i saw the plugin named "Stat render", using forumhome_complete, i just want to show the stat for admin only, here is the complete code:

if (is_member_of($bbuserinfo, 6)) {

if (($vbulletin->options['glowhostspamomatic_stat_show_denied'] == 1) || ($vbulletin->options['glowhostspamomatic_stat_show_banned'] == 1)) {
//$vbulletin->

$stats = $vbulletin->db->query_first("SELECT * FROM " . TABLE_PREFIX . "glowhostspamomatic_stats");

//echo '<pre>';
//print_r($vbulletin->stylevars['imgdir_misc']);
//echo '</pre>';

$template_hook[forumhome_wgo_pos2] .= '

<div class="wgo_subblock section">
<h3 class="blocksubhead"><img src="'.$vbulletin->stylevars['imgdir_misc']['imagedir'].'/forum_stats.png" alt="Spam-O-Matic Statistics" />';

if ($vbulletin->options['glowhostspamomatic_stat_show_link'] == 1) {
$template_hook[forumhome_wgo_pos2] .= '<a href="https://vborg.vbsupport.ru/showthread.php?t=248042" target="_blank">Spam-O-Matic Statistics</a>';
} else {
$template_hook[forumhome_wgo_pos2] .= 'Spam-O-Matic Statistics';
}


$template_hook[forumhome_wgo_pos2] .= ' </h3>
<div>';

if (($vbulletin->options['glowhostspamomatic_stat_show_denied'] == 1) && ($stats['denied'] > 0)) {
$template_hook[forumhome_wgo_pos2] .= '<p>'.$stats['denied'].' Spammer'.(($stats['denied'] > 1)?'s':'').' Denied Registration</p>';
}

if (($vbulletin->options['glowhostspamomatic_stat_show_banned'] == 1) && ($stats['banned'] > 0)) {
$template_hook[forumhome_wgo_pos2] .= '<p>'.$stats['banned'].' Spammer'.(($stats['banned'] > 1)?'s':'').' Permanently Banned</p>';
}

if (($vbulletin->options['glowhostspamomatic_stat_show_s_sfs'] == 1) && ($stats['s_sfs'] > 0)) {
$template_hook[forumhome_wgo_pos2] .= '<p>'.$stats['s_sfs'].' Spammer'.(($stats['s_sfs'] > 1)?'s':'').' submitted to StopForumSpam</p>';
}

if (($vbulletin->options['glowhostspamomatic_stat_show_s_akismet'] == 1) && ($stats['s_akismet'] > 0)) {
$template_hook[forumhome_wgo_pos2] .= '<p>'.$stats['s_akismet'].' Spammer'.(($stats['s_akismet'] > 1)?'s':'').' submitted to Akismet</p>';
}

if (($vbulletin->options['glowhostspamomatic_stat_show_mod'] == 1) && ($stats['moderated'] > 0)) {
$template_hook[forumhome_wgo_pos2] .= '<p>'.$stats['moderated'].' Spammy Post'.(($stats['moderated'] > 1)?'s':'').' Automatically Moderated</p>';
}

if (($vbulletin->options['glowhostspamomatic_stat_show_removed'] == 1) && ($stats['removed'] > 0)) {
$template_hook[forumhome_wgo_pos2] .= '<p>'.$stats['removed'].' Spammy Post'.(($stats['removed'] > 1)?'s':'').' Removed</p>';
}

$template_hook[forumhome_wgo_pos2] .= ' </div>
</div>
';

}

}

but the code above hide the stat to all usergroup.

kh99
06-15-2013, 07:45 AM
OK, I think you should use:
if (is_member_of($vbulletin->userinfo, 6)) {

if you haven't tried that already. $bbuserinfo is a shortcut that only works in a template.

Gripi
06-15-2013, 07:26 PM
Hello..

Thank you.. working now :)