MyBB Community Forums

Full Version: If statement with reputation to show colors
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Is there an if statement via php template conditionals for positive, neutral and negative reputation?

I have reputation displaying via UserCP:
[Image: sosqpt.png]

I'd like it to be grey when neutral, green when positive, red when negative.
This is what's calling the number right now:
<a href="reputation.php?uid={$mybb->user['uid']}">{$mybb->user['reputation']}</a>

Wondering if someone can help me do it with the colors.
Link to your forum?
Can anyone help with this?
If you post a link to your forum we can actually look at your theme code and help you...
I just posted it.

<a href="reputation.php?uid={$mybb->user['uid']}">{$mybb->user['reputation']}</a>
^ That is NOT a link to your forum.
Do you just need an if statement or do you also want us to restyle your div rep boxes?

If you want us to restyle then we'd need your link.
It should be like this, but I don't have experience with this plugin

replace:
<a href="reputation.php?uid={$mybb->user['uid']}">{$mybb->user['reputation']}</a>

with:
<?php
if($mybb->user['reputation'] == 0)
{
    $colorstyle = ' style="color: grey;"';
}
elseif($mybb->user['reputation'] <= '-1')
{
    $colorstyle = ' style="color: red;"';
}
elseif($mybb->user['reputation'] >= 1)
{
    $colorstyle = ' style="color: green;"';
}
?>

<a href="reputation.php?uid={$mybb->user['uid']}"{$colorstyle}>{$mybb->user['reputation']}</a>
(2017-03-01, 03:34 PM)SvePu Wrote: [ -> ]It should be like this, but I don't have experience with this plugin

replace:
<a href="reputation.php?uid={$mybb->user['uid']}">{$mybb->user['reputation']}</a>

with:
<?php
if($mybb->user['reputation'] == 0)
{
    $colorstyle = ' style="color: grey;"';
}
elseif($mybb->user['reputation'] <= '-1')
{
    $colorstyle = ' style="color: red;"';
}
elseif($mybb->user['reputation'] >= 1)
{
    $colorstyle = ' style="color: green;"';
}
?>

<a href="reputation.php?uid={$mybb->user['uid']}"{$colorstyle}>{$mybb->user['reputation']}</a>

Or you could use the get_reputation() function.
Whats the get_reputation() function?

(2017-03-01, 03:34 PM)SvePu Wrote: [ -> ]It should be like this, but I don't have experience with this plugin

replace:
<a href="reputation.php?uid={$mybb->user['uid']}">{$mybb->user['reputation']}</a>

with:
<?php
if($mybb->user['reputation'] == 0)
{
    $colorstyle = ' style="color: grey;"';
}
elseif($mybb->user['reputation'] <= '-1')
{
    $colorstyle = ' style="color: red;"';
}
elseif($mybb->user['reputation'] >= 1)
{
    $colorstyle = ' style="color: green;"';
}
?>

<a href="reputation.php?uid={$mybb->user['uid']}"{$colorstyle}>{$mybb->user['reputation']}</a>

It's also not a plugin, it's the usercp template.
Pages: 1 2