vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Plugin code to show for specific usergroup only (https://vborg.vbsupport.ru/showthread.php?t=299123)

Gripi 06-14-2013 06:18 PM

Plugin code to show for specific usergroup only
 
Hello..

how to change this code to work inside the plugin:

show to specific group only:

PHP Code:

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

i already try:

PHP Code:

if (is_member_of($vbulletin->userinfo123)) {



but no luck.

thanks

kh99 06-14-2013 06:32 PM

That should work. Which hook are you using? You may need to add
Code:

global $vbulletin;

to the beginning of your plugin code.

Gripi 06-15-2013 03:38 AM

Hello.. not working..

i use it in forumhome_complete

kh99 06-15-2013 06: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 06: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:

PHP Code:

if (is_member_of($bbuserinfo6)) {

                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 06:45 AM

OK, I think you should use:
Code:

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 06:26 PM

Hello..

Thank you.. working now :)


All times are GMT. The time now is 06:47 PM.

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.01778 seconds
  • Memory Usage 1,764KB
  • 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
  • (2)bbcode_code_printable
  • (3)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)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