MyBB Community Forums

Full Version: Avatar maximum dimensions set by usergroup problem
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I've adapted some code taken from another thread (which for the love of me I cannot find), which sets the maximum dimensions of an avatar based on the usergroup GID called from an array. It depends on the plugin 'Template Conditionals' being installed in order to allow PHP in templates.

The code works to resize the dimensions of the avatar, but the array is not working. The array should make usergroups like Administrators and Moderators have a larger avatar size, but it is skipping the code and going straight to the 'else' part. I can't seem to see the problem with my code, it just won't work at all!

The code is placed in the "postbit_avatar" template and replaces the default code.



Quote:<a href="{$post['profilelink_plain']}">
<img src="{$post['avatar']}" alt="" <if (in_array($mybb->user['usergroup'] , array('3','4','6','10','15'))) then>
style="max-width:150px; max-height: 200px"<else>
style="max-width:100px; max-height: 100px"</if>/>
</a>

If anyone can see what I'm doing wrong with my code, or has any suggestions for a potential workaround (plugins, edits to base php or templates) then I would be highly appreciative.
You may be better of changing this during the upload process.
https://github.com/Sama34/OUGC-Avatar-Se...roup-Basis

I think $mybb->user should be $post in your code.
Switching $mybb->user to $post didn't solve this problem, however setting the maximum display value to 150x200 in the admincp and then installing your suggested plugin did.

Thanks for the help, honestly I spent a few days looking for a plugin that does that Smile