Add-on [Paid] Forum Permission-Based User Images

taylor_smith

Well-known member
I'm hoping to persuade someone to create a plugin that designates usergroup images in the postbit based on forum permissions.

With our current software, our staff are represented by different badges:

admin.gif
mod.gif
staff.gif
vip.gif


These badges are not based on usergroups, but rather on permissions. For example, when a staff member has moderator rights in a particular forum, her username looks like this:

mod.png


However, in forums where the user has no moderator permissions, her username appears as follows:

staff.png


Occasionally, we allow normal users to mod forums for their guilds/clans. In these cases, the user has a green moderator badge in his or her guild/clan forum, but appears as a normal user everywhere else--no staff badge or title.

In our current software, we have added the following code to the postbit template (abridged for space, but conveys the general idea):

Code:
<if condition="can_moderate($forum[forumid], '', $post[userid]) AND !($post[usergroupid]==6 )"><div class="smallfont"><img src ="mod.gif">&nbsp;<a class="bigusername" href="member.php?$session[sessionurl]u=$post[userid]">$post[musername]</a></div><else />
<if condition="($post[usergroupid]==11 OR IS_MEMBER_OF($post, 11))"><div class="smallfont"><img src ="staff.gif">&nbsp;<a class="bigusername" href="member.php?$session[sessionurl]u=$post[userid]">$post[musername]</a></div><else />
<div class="smallfont"><a class="bigusername" href="member.php?$session[sessionurl]u=$post[userid]">$post[musername]</a></div>
</if></if></if>
                <script type="text/javascript"> vbmenu_register("postmenu_$post[postid]", true); </script>
                <else />
                $post[musername]
                </if>
            </div>

Ideally, the badges should appear in the postbit below the avatar, to the left of the username. Will pay $20 USD for a plugin that achieves this same effect in XenForo.
 
Looking at this code, I noticed something. Basically, if a user is one of our administrator usergroups, the template edit forces the "A" badge in all forums, regardless of whether the admin is assigned as a mod. For all non-admin usergroups, the template edit forces an "M" badge if the user is assigned as a mod. If the user is not assigned as a mod, it'll show their normal user image--either an "S" badge or no image.
 
You could probably build this with a bit of help. It's 3 parts.

PART 1 Upload your two icons to your directory \styles\default
(check that's your image path, it's the standard one)
then you can use this short code to link to them.

Code:
<img src="@imagePath/GREEN_ICON.png" / >
this assumes the image is .png but it could be .jpg or .gif
which will be obvious when uploading it
be careful to use binary upload mode as I've found XF can be sensitive to that.

PART 2 Next in the Styles and Customisation forum here ask which template to edit
to insert an icon to the left of the username in the postbit.
Include your helpful mockups as you did here.
Someone will tell you it's xxxxxx template.
Keep their post open inh a tab next to your admincp tab.

In admincp go to Appearances/ Templates
then put that template name in the search box.
Your helpers/s will probably tell you to look for a specific line of code - this is your landmark.
Click in a white area of the code in the text area (edit box).
Use Ctrl+F on the keyboard/ enter a piece of the landmark code to find it.
Double check the landmark line of code really matches your guide on here.

Your helper will tell you exactly where to insert your image code.
Use ONE of your icons just to test.
Be careful not to disturb any commas brackets etc - anything already there.
Click Save. If you've done anything really awful XF will protect you and refuse to Save it!

Refresh a page that shows someone's postbit. You have so far placed this icon beside EVERYONE! so you should see it.
If not double check you obeyed instructions exactly.
If it creates a mess on the page panic not. Back in admincp you can use the Revert button, bottom of the template, to remove what you did.
Ask for help. Try again.

PART 3. Conditionals.
Next you need to work on the conditional for each situation.
So the conditional would run something like -
IF this user IS MODERATOR in THIS FORUM then display ICON_GREEN
ELSE IF this user IS NOT MODERATOR in THIS FORUM then display ICON_BLUE.

You can ask on the coding forum for a basic conditional to insert an image
Say you want both IF and IF ELSE to cover " is moderator" and "is not moderator"


It feels great when you get it to work. I won't say condescending things like it's easy. Nothing is the first time. But it's not terribly difficult either.
 
Curse my shameful technical ineptitude, but I will give it a shot. I genuinely appreciate your insight on this matter.

Would still pay someone for a plugin and would negotiate on the amount. Nevertheless, while I have the test forum set up, I suppose it won't matter if I break everything.
 
:) You won't break everything I promise
This is your rescue if it doesn't go right.

Revert.webp

It just strips out ALL you added and returns the template to its original state.

Building it yourself can take several days as you get a series of bits of help.
But it is such fun seeing what YOU do showing up!

Bit annoying when you carefully put it in and nothing happens!
But keep trying and asking for help.

It can take weeks to find a persuade a coder to do it for you :(
 
Can you give me a quick overview of each badge and when it would display?
mod.gif
- displays when user is a mod of this forum
staff.gif
- displays when user is moderator, but not in this forum?
vip.gif
- displays when?
admin.gif
- displays when?

Also, would there ever be 2 badges displayed at the same time? If a user was mod, staff, VIP and admin, would all 4 badges display?
 
mod.gif
- displays when user is a mod of this forum.
staff.gif
- displays when user is in the Staff usergroup. Also displays when a user is in the Moderators usergroup, but not a mod in this forum.
vip.gif
- displays user is in a VIP group (we give this to game developers, producers, etc.).
admin.gif
- displays when user is in an Administrator or Forum Administrator usergroup.

So, the main difference here relates to the
mod.gif
badge. We offer guilds free forum hosting. We assign them as mods for their forums, but don't stick them in the Moderators usergroup. As a result, they see the
mod.gif
badge when they're in their forum, but everywhere else on the site they appear as just a normal user. Additionally, when someone is a both a moderator and in the Moderators usergroup (i.e., they're on staff--not just some guild leader), they see
mod.gif
when they're a mod in this forum and
staff.gif
when they're not.

Honestly, if this is this too difficult to do, I would be content with just some instructions for adding images to usergroups. I think our guild mods can deal with not having a
mod.gif
by their name. Also, the harder this gets to do, the less attached I am to the idea that mods see
mod.gif
in their forums but
staff.gif
otherwise. I'm really starting to lean in this direction. -_-

I found this: http://xenforo.com/help/user-group-styling/. I'll give it a try, in case the above is too difficult to be worth it.
 
Quick question:
Would you want multiple badges to display? Let's say you have a guild moderator who is also a VIP member, would you want M and V to appear next to their name, or would you prefer just one of them?
 
I've got this working great, except for one minor flaw that I'm hoping to sort out.

When you're a moderator, it shows you with the Green M all over instead of just in that specific forum.

EDIT: OK now I've got it working in a way where you have to be a moderator of a specific node ID (i.e. not a parent) in order for it to work.

Will try and rewrite my moderator function tomorrow.
 
Top Bottom