The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
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&userlist=friend&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>'; } The uploaded attachment is a screenshot of the postbit buttons from Guest View. |
#2
|
|||
|
|||
I believe a way to check if the user is logged in is to check if the $vbulletin->userinfo['userid'] variable is set
|
#3
|
||||
|
||||
Quote:
I tried that, but nothing happens. |
#4
|
|||
|
|||
Can you copypaste the code here?
|
#5
|
||||
|
||||
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&userlist=friend&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>'; |
#6
|
||||
|
||||
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? |
#7
|
||||
|
||||
Quote:
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&userlist=friend&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"> </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&u={vb:raw post.userid}" rel="nofollow"><img src="{vb:raw vboptions.cleargifurl}" alt="{vb:rawphrase send_pm}" />PM</a><span class="seperator"> </span></vb:if></vb:if> <!-- Send PM Button - End --> Anyways, Thank you everyone for trying to help me!! I greatly appreciate your time! |
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|