MyBB Community Forums

Full Version: Add PM Button Somewhere Else and Referrals on Postbit?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey there. I'd like to add PM button to hovercards. The deal is that when I do, I can see it on my hovercard too. In postbit, there's no PM button my post. 

I also added referrals count to postbit and I'd like to behave just like in member profile, when clicked on the number, it'll show me the members referred but it doesn't in postbit, popup won't open.


I've been encountering similiar problems quite often. I want to replace or add else where a functioning button but it doesn't work as it should.

The main question I have here is that how can I manage to create or replace a piece of code (a button, a link, a style etc.) to make it visible only to all users except me, or on some forums/categories and not on some, or only to me (or to a certain group or uid) and no one else, or just like PM button, I'll be seeing it on other users but not on me.

I'm doing something wrong that sometimes in some cases, when I add a piece of code somewhere else or replace it, it redirects me to my profile/my post etc. instead of the members, or when I add a style on it, the button/link dissappears when it should (no problem here) but the style remains visible, or the code is always visible to anyone.

Thank you!
Any help?
The problem remains.
You won’t be able to copy a button from one place and put it somewhere else, that’s fully expected - if there’s not the PHP behind it to populate or define a variable or the JavaScript isn’t there to open a popup, it won’t do it. For example, what code did you put in the postbit for the referral popup? If the user ID isn’t defined or the JavaScript isn’t defined, it’s not going to work. Even if it is, then if it’s a button that is only supposed to show under certain conditions, the PHP that determines that won’t be running on the thread page if the button is originally from the member profile.

You’d need a plug-in to redefine whether a button can show based on usergroup or what forums you’re in.
(2021-09-26, 11:06 AM)Matt Wrote: [ -> ]You won’t be able to copy a button from one place and put it somewhere else, that’s fully expected - if there’s not the PHP behind it to populate or define a variable or the JavaScript isn’t there to open a popup, it won’t do it. For example, what code did you put in the postbit for the referral popup? If the user ID isn’t defined or the JavaScript isn’t defined, it’s not going to work. Even if it is, then if it’s a button that is only supposed to show under certain conditions, the PHP that determines that won’t be running on the thread page if the button is originally from the member profile.

You’d need a plug-in to redefine whether a button can show based on usergroup or what forums you’re in.

Thank you for the reply! I'm actually aware why it doesn't work but just was just wondering if a javascript and/or php works in, for example, postbit template, can I not make it also work in another template, without having to code a plug-in? As you said, JavaScript is there, PHP is there but not for the template I need, so, is there a way to define it for other templates as well? Would it cause performance/security issues? Here is the code for referral count on my postbit.

<div class="pbrow"><div class="pbico"><i class="fas fa-user-plus fa-lg"></i></div><div class="pbrowin"><span style="float: left">Referanslar:</span><span style="float: right"><a href="{$mybb->settings['bburl']}/member.php?action=referrals&amp;uid={$post['uid']}" id="referrer_{$pid}" class="referralLink">{$post['referrals']}</a></span></div></div>		
Because the same PHP run in one place isn't run in other places. For the profile, $memprofile['referrals'] is available from the profile being viewed, but $post['referrals'] isn't defined when building the postbit, so you'd need a plugin to define that value.