vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Requests/Questions (Unpaid) (https://vborg.vbsupport.ru/forumdisplay.php?f=112)
-   -   How to hide this? (https://vborg.vbsupport.ru/showthread.php?t=268443)

Divvy 08-13-2011 12:06 AM

How to hide this?
 
Hello guys,

Maybe someone can help me...

I have this code:
PHP Code:

$template_hook['postbit_userinfo_right_after_posts'] .= '<div style="clear:both;" class="left"><a target="_blank" href="'.$mylink.''.$usernumber.'">'.$mylinktitle.'</a></div>'

That shows a link at postbit with all topics from the user at a two specific forums.

I need that:
- the link only shows when the user have threads at least in one of that two forums.
- If not, the link doesn't appear.

It is possible? Please? :)

Or else, I had another idea...
The links only appear If the user belongs to a specific group.

BirdOPrey5 08-13-2011 07:13 PM

Quote:

Originally Posted by Divvy (Post 2232852)
Hello guys,

Maybe someone can help me...

I have this code:
PHP Code:

$template_hook['postbit_userinfo_right_after_posts'] .= '<div style="clear:both;" class="left"><a target="_blank" href="'.$mylink.''.$usernumber.'">'.$mylinktitle.'</a></div>'

That shows a link at postbit with all topics from the user at a two specific forums.

I need that:
- the link only shows when the user have threads at least in one of that two forums.
- If not, the link doesn't appear.

It is possible? Please? :)

Or else, I had another idea...
The links only appear If the user belongs to a specific group.

It would be much easier to show it based on usergroup. That code would be:

PHP Code:

if (is_member_of($vbulletin->userinfo2))
{
   
$template_hook['postbit_userinfo_right_after_posts'] .= '<div style="clear:both;" class="left"><a target="_blank" href="'.$mylink.''.$usernumber.'">'.$mylinktitle.'</a></div>';


Where "2" is the usergroupid... you can change that to whatever usergroupid you want. Primary or secondary. You can also do additional groups by adding more such as:
PHP Code:

if (is_member_of($vbulletin->userinfo2,5,6,7)) 

Would work for users in groups 2, 5, 6, and 7.

Depending on the hook you may need to make $vbulletin global if you aren't using it already. Doesn't hurt to put this line at the top of the plugin or php code if you haven't already:
PHP Code:

global $vbulletin

As for your other way, depending on posts in specific forums, that would require custom coding and an additional database query to get that info so this is easier and more efficient code.

Divvy 08-13-2011 09:26 PM

hi mate, thank you for your reply :)

I tried your code but didnt work, It shows this errors:
Code:

Parse error: syntax error, unexpected $end in /home/vns/public_html/forum/includes/class_postbit.php(340) : eval()'d code on line 67
here is my full plugin code:
PHP Code:

if ($vbulletin->options['ecpl_Online'] == 1)
 {
 
$mylink $vbulletin->options['ecpl_link'];
 
$mylinktitle $vbulletin->options['ecpl_link_title'];
 if (
$vbulletin->options['ecpl_unique_number'])
   {
    
$usernumber ''.$post[userid].'';
   }
 else
   {
    
$usernumber '';
   }

 
$template_hook['postbit_userinfo_right_after_posts'] .= '<div style="clear:both;" class="left"><a target="_blank" href="'.$mylink.''.$usernumber.'">'.$mylinktitle.'</a></div>';
 } 

Any idea? :)

BirdOPrey5 08-14-2011 12:28 AM

Quote:

Originally Posted by Divvy (Post 2233174)
hi mate, thank you for your reply :)

I tried your code but didnt work, It shows this errors:
Code:

Parse error: syntax error, unexpected $end in /home/vns/public_html/forum/includes/class_postbit.php(340) : eval()'d code on line 67
here is my full plugin code:
PHP Code:

if ($vbulletin->options['ecpl_Online'] == 1)
 {
 
$mylink $vbulletin->options['ecpl_link'];
 
$mylinktitle $vbulletin->options['ecpl_link_title'];
 if (
$vbulletin->options['ecpl_unique_number'])
   {
    
$usernumber ''.$post[userid].'';
   }
 else
   {
    
$usernumber '';
   }

 
$template_hook['postbit_userinfo_right_after_posts'] .= '<div style="clear:both;" class="left"><a target="_blank" href="'.$mylink.''.$usernumber.'">'.$mylinktitle.'</a></div>';
 } 

Any idea? :)

Given that code I would put it as part of the main/top condition...


PHP Code:

if ($vbulletin->options['ecpl_Online'] == AND is_member_of($vbulletin->userinfo,2))
 {
 
$mylink $vbulletin->options['ecpl_link'];
 
$mylinktitle $vbulletin->options['ecpl_link_title'];
 if (
$vbulletin->options['ecpl_unique_number'])
   {
    
$usernumber ''.$post[userid].'';
   }
 else
   {
    
$usernumber '';
   }

 
$template_hook['postbit_userinfo_right_after_posts'] .= '<div style="clear:both;" class="left"><a target="_blank" href="'.$mylink.''.$usernumber.'">'.$mylinktitle.'</a></div>';
 } 


Divvy 08-14-2011 01:35 AM

Thank you again for your reply BirdOPrey5 :)

I think that the code is correct now, but is not what Im looking for... my english is a little poor, and maybe you didnt understood well my request hehe

Explaining again:
That plugin code that I posted is from this mod:
https://vborg.vbsupport.ru/showthread.php?t=235619

The mod adds a custom link to the postbit, the default is user album link, but I changed to appear the topics that user started in two specific forums.

By default, the link appears to ALL members, even the ones that dont have any topics created in those two forums.
For example, below of the avatar will appear "My topics" link.
My idea is to show that link only to the users that have topics created in those two forums.
If the user dont have any topics created in those two forums, the link dont appear.

Got the idea? :)

I give the usergroup idea, because I add my users to a specific group If they created a topic in those two forums. So If they belong to that group, is because they started a topic in one of those two forums.

Sorry for the trouble...
Any idea how to make this like I want? :)

BirdOPrey5 08-14-2011 10:22 AM

If you add people to the usergroup the code I have should work. You need to change the number 2 in the is_member_of function to the usergroupid of the usergroup you add members to. 2 was just an example, it shows to all registered users- I would have no idea what the real usergroupid is on your forum.

Divvy 08-14-2011 10:50 AM

ohhh damn... I have read my explanation and I think that I explained wrong again :/
very sorry mate...

I know that your code works fine! I tried with usergroupid 6 that is administrators and only admins see the link...

But is not what I want lol.

Let me try explain again:
I want to show the link to everyone! but If the user belongs to specific usergroups, the link will appear (to everyone), If the user dont belongs to that specific usergroups, the link will not appear to anyone.

For example, please check:
http://screensnapr.com/e/g8ii2H.jpg

In link above, only the user Ruimaisluisa belongs to the usergroup that I want.
And Green_Boy dont belongs.
But as you can see, the link that says "As minhas fotos" appears to both.
I want to appear only to user Ruimaisluisa, for example :)

nerbert 08-14-2011 12:23 PM

I think this does it:

Product: vBulletin

Hook location: showthread_postbit_create

Title: Find Qualified Members

Exectuion order: 5

Plugin PHP code:

PHP Code:

if($vbulletin->userinfo['userid'] == 5)
{
    
ini_set('display_errors''1');
        
$db->show_errors(); 
// REMOVE THE STUFF ABOVE WHEN EVERYTHING IS WORKING

    
$thread_count $db->query_read("
        SELECT COUNT(*)
        FROM " 
TABLE_PREFIX "thread
        WHERE postuserid = " 
$post[userid] . "
        AND (forumid = 6 
        OR forumid = 7)
    "
);
    
$templater->register('thread_count'$thread_count); 

// REMOVE THE STUFF BELOW WHEN EVERYTHING IS WORKING
        
$db->hide_errors();



Put in YOUR user id in the first line and YOUR forumids. When everything is working get rid of the stuff at the top and bottom so everyone can see it.

Now you can use a template conditional:

<vb:if condition="$thread_count > 0"> ................. </vb:if>

I think this will work.

BirdOPrey5 08-14-2011 12:50 PM

Ahhh...

Try sing $post instead of $vbulletin->userinfo in the is_member_of() function.

edited.

Divvy 08-14-2011 01:39 PM

Thank you for your reply nerbert, and for trying to help me :)

I created an plugin like you said:
PHP Code:

if ($vbulletin->options['ecpl_Online'] == 1)
 {
 
$mylink $vbulletin->options['ecpl_link'];
 
$mylinktitle $vbulletin->options['ecpl_link_title'];
 if (
$vbulletin->options['ecpl_unique_number'])
   {
    
$usernumber ''.$post[userid].'';
   }
 else
   {
    
$usernumber '';
   }

 
$template_hook['postbit_userinfo_right_after_posts'] .= '<vb:if condition="$thread_count > 0"><div style="clear:both;" class="left"><a target="_blank" href="'.$mylink.''.$usernumber.'">'.$mylinktitle.'</a></div></vb:if>';
 } 

And changed this:
PHP Code:

$template_hook['postbit_userinfo_right_after_posts'] .= '<div style="clear:both;" class="left"><a target="_blank" href="'.$mylink.''.$usernumber.'">'.$mylinktitle.'</a></div>'

to this:
PHP Code:

$template_hook['postbit_userinfo_right_after_posts'] .= '<vb:if condition="$thread_count > 0"><div style="clear:both;" class="left"><a target="_blank" href="'.$mylink.''.$usernumber.'">'.$mylinktitle.'</a></div></vb:if>'

But when I try to see a topic, I get this error:
Quote:

Fatal error: Call to a member function register() on a non-object in /home/viciados/public_html/forum/showthread.php(1053) : eval()'d code on line 14
What I did wrong?

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

BirdOPrey5, thank you for keep helping me :)

I did what you said, but didnt work... the link disappeared in all users.

What I added:
PHP Code:

if ($vbulletin->options['ecpl_Online'] == AND is_member_of($post->userinfo,27,17,13,18,14))
 {
 
$mylink $vbulletin->options['ecpl_link'];
 
$mylinktitle $vbulletin->options['ecpl_link_title'];
 if (
$vbulletin->options['ecpl_unique_number'])
   {
    
$usernumber ''.$post[userid].'';
   }
 else
   {
    
$usernumber '';
   }

 
$template_hook['postbit_userinfo_right_after_posts'] .= '<div style="clear:both;" class="left"><a target="_blank" href="'.$mylink.''.$usernumber.'">'.$mylinktitle.'</a></div>';
 } 

27,17,13,18,14 are the usergroupids that I want link appear.


All times are GMT. The time now is 06:26 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.04074 seconds
  • Memory Usage 1,827KB
  • 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
  • (13)bbcode_php_printable
  • (3)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