Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 General Discussions
  #1  
Old 07-17-2014, 06:38 PM
thetechgenius's Avatar
thetechgenius thetechgenius is offline
 
Join Date: Jun 2014
Posts: 258
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Help with hiding postbit buttons from guests

I added 2 plugins to add a "Send PM" button and a "Add Friend" button to the bottom of the postbit. The only problem is, they are visible to everyone, including users not logged in. The other default buttons are only visible to Logged-In users, so it looks weird to see only the 2 buttons visible.


Here is my code for the "Add Friend" button:

Plugin PHP Code
Code:
$postuserinfo = fetch_userinfo($post['userid'], 128);
$isfriend = $postuserinfo['isfriend'];
if (!$isfriend)
{
    $template_hook['postbit_controls'] .= '<span class="addfriend"><a href="profile.php? ' . $vbulletin->session->vars['sessionurl'] . 'do=addlist&amp;userlist=friend&amp;u=' . $post['userid'] . '">' . construct_phrase($vbphrase['add_as_friend'], $post['username']) . '<img class="addimg" alt="Add as Friend" src="images/site_icons/add.png"></a><span class="seperator"></span></span>';
}


Here is my code for the "Send PM" button:

Plugin PHP Code
Code:
$postuserinfo = fetch_userinfo($post['userid'], 128);

{
    $template_hook['postbit_controls'] .= '<span class="sendpm"><a href="private.php? ' . $vbulletin->session->vars['sessionurl'] . 'do=newpm&u=' . $post['userid'] . '">' . construct_phrase($vbphrase['send_pm'], $post['username']) . '<img class="pmimg2" alt="Send PM" src="images/site_icons/pm.png"></a><span class="seperator"></span></span>';
}
What code do I add to these plugins to make them only visible to Registered Users?

The uploaded attachment is a screenshot of the postbit buttons from Guest View.
Attached Images
File Type: png postbit_buttons.png (3.4 KB, 0 views)
Reply With Quote
  #2  
Old 07-17-2014, 07:02 PM
Dave Dave is offline
 
Join Date: May 2010
Posts: 2,583
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I believe a way to check if the user is logged in is to check if the $vbulletin->userinfo['userid'] variable is set
Reply With Quote
  #3  
Old 07-17-2014, 09:09 PM
thetechgenius's Avatar
thetechgenius thetechgenius is offline
 
Join Date: Jun 2014
Posts: 258
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Dave View Post
I believe a way to check if the user is logged in is to check if the $vbulletin->userinfo['userid'] variable is set

I tried that, but nothing happens.
Reply With Quote
  #4  
Old 07-17-2014, 09:09 PM
Dave Dave is offline
 
Join Date: May 2010
Posts: 2,583
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Can you copypaste the code here?
Reply With Quote
  #5  
Old 07-17-2014, 09:38 PM
thetechgenius's Avatar
thetechgenius thetechgenius is offline
 
Join Date: Jun 2014
Posts: 258
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Dave View Post
Can you copypaste the code here?
The code is in the first post.

I tried this:

Code:
$postuserinfo = fetch_userinfo($post['userid'], 128);
$isfriend = $postuserinfo['isfriend'];
if (!$isfriend)
if ($vbulletin->userinfo['userid'])
{
    $template_hook['postbit_controls'] .= '<span class="addfriend"><a href="profile.php? ' . $vbulletin->session->vars['sessionurl'] . 'do=addlist&amp;userlist=friend&amp;u=' . $post['userid'] . '">' . construct_phrase($vbphrase['add_as_friend'], $post['username']) . '<img class="addimg" alt="Add as Friend" src="images/site_icons/add.png"></a><span class="seperator"></span></span>';
And that removes the "Add Friend" button completely from the postbit, so no usergroups can see it.
Reply With Quote
  #6  
Old 07-18-2014, 12:50 AM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

We want to see the code with your added condition that you tried.

Also, what hook locations? What was the result? What is the full code (your's don't have closing "if" tags)?

Can you explain exactly what your code is supposed to do?
Reply With Quote
  #7  
Old 07-18-2014, 01:34 AM
thetechgenius's Avatar
thetechgenius thetechgenius is offline
 
Join Date: Jun 2014
Posts: 258
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Lynne View Post
We want to see the code with your added condition that you tried.

Also, what hook locations? What was the result? What is the full code (your's don't have closing "if" tags)?

Can you explain exactly what your code is supposed to do?

Here is a screenshot of the plugin I created. The plugin just adds an "Add Friend" button at the bottom of the postbit, right next to the "Edit Post" and "Quote" buttons:





Here is an image of the plugin being rendered on the postbit:





I just need to know how to get the buttons to show only to "Registered Users". Right now everyone can see the button, including Guests. As you can see in the second screenshot, just the 2 buttons are being shown, and not the rest. Thats because the other buttons are the default buttons, and they only show up if the User is Logged-In.

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

Never mind. I found out a way to do this. I disabled the plugins I created, and just put the code directly into the template.

Right before the "Edit Post" button is rendered, I added this code for the PM and Add Friend buttons:

Code:
<!-- Add Friend Button - Begin -->
<vb:if condition="!is_member_of($bbuserinfo, 1,8)">
<vb:if condition="$show['pmlink']">
<span class="addfriend"><a href="profile.php?{vb:raw session.sessionurl}do=addlist&amp;userlist=friend&amp;u={vb:raw post.userid}"><img class="addimg" alt="Add as Friend" src="images/site_icons/add.png">Add as Friend</a><span class="seperator">&nbsp;</span></span></vb:if></vb:if>
<!-- Add Friend Button - End -->


<!-- Send PM Button - Begin -->
<vb:if condition="!is_member_of($bbuserinfo, 1,8)">
<vb:if condition="$show['pmlink']"><a class='pminpostbit' href="private.php?{vb:raw session.sessionurl}do=newpm&amp;u={vb:raw post.userid}" rel="nofollow"><img src="{vb:raw vboptions.cleargifurl}" alt="{vb:rawphrase send_pm}" />PM</a><span class="seperator">&nbsp;</span></vb:if></vb:if>
<!-- Send PM Button - End -->
And I added some CSS to the Span Classes for the buttons in additional.css

Anyways, Thank you everyone for trying to help me!! I greatly appreciate your time!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:39 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.09666 seconds
  • Memory Usage 2,243KB
  • Queries Executed 12 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (4)bbcode_code
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (1)postbit_attachment
  • (7)postbit_onlinestatus
  • (7)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete