Your take on the method used for this Addon?


Active member
Addon Goal: To make the signatures of 1 usergroup visible to "Guests/Not Registered".

Global setting is to hide all signatures from "Guests".


Method used: Developer decided to enable signatures to be viewable by all Guests, and then created a conditional to check for who posted the new message and then decide whether it should be hidden. Since 99% of our 60,000 users (with 170,000 posts) will not be in the usergroup mentioned, this check is going to perform its "function" countless times a day.

I am concerned that this method is a lot more intensive than doing it the other way around. Enabling certain signatures to be visible from a very tiny usergroup (5 members) versus making them visible to everyone and "manually" hiding "everyone elses" every time a post is viewed. There are only 5 people in the usergroup mentioned. (but I know absolutely nothing - this is just a hunch)

Can you think of a cleaner, less "heavy" way of implementing the end goal? Or is this pretty awesome? (I didnt write it)


Question posed to developer: "Thank you so much. Does this modification for signatures slow down the site at all? When it has to do a real-time check on something every single time a thread is viewed"

Response: "I kept that in mind, the initial idea was to query the database but then that would’ve meant doubling the queries. I modified it so that it doesn’t need to make addition access to database for this check. I checked the performance after the change and it is unchanged."

Question: "Is this the methodology used for every single setting in the permissions area? It seems like that would be incredibly heavy code. How do they hide and show things to people with the other options on the permissions page?"

Response: "They extract the permissions for the visitor checking the website and that includes every permission he has. Then it is just a super fast look up to the list of permissions he has to know what should happen."

Question: "Why couldn't we use the same approach for this permissions setting?"

Response: "Because we didn’t have permissions for the users in the message array for 20 users. We could’ve extended the current message function and added this thing which would’ve put additional load on database. But here I just extracted the permission ID and secondary permission ID and checked if the poster is a member of that particular user group."

"This uses a helper function. This method utilizes the XenForo built function in the User class which returns true if the user is a member of the sponsor user group:"

public static function helperIsMemberOf(array $user, $userGroupId, $multipleIds = null)
  if (!is_null($multipleIds))
   // check multiple groups
   $userGroupId = array_slice(func_get_args(), 1);

  return self::_getModelFromCache('XenForo_Model_User')->isMemberOfUserGroup($user, $userGroupId);

Rest of code mentioned above:

<xen:require css="message.css" />
<xen:require css="bb_code.css" />

<li id="{$messageId}" class="message {xen:if $message.isDeleted, 'deleted'} {xen:if '{$message.is_staff}', 'staff'} {xen:if $message.isIgnored, ignored}" data-author="{$message.username}">

    <xen:include template="message_user_info">
        <xen:map from="$message" to="$user" />

    <div class="messageInfo primaryContent">
        <xen:if is="{$message.isNew}"><strong class="newIndicator"><span></span>{xen:phrase new}</strong></xen:if>
        <xen:if hascontent="true">
            <ul class="messageNotices">
                    <xen:hook name="message_notices" params="{xen:array 'message={$message}'}">
                        <xen:if is="{$message.warning_message}">
                            <li class="warningNotice"><span class="icon Tooltip" title="{xen:phrase warning}" data-tipclass="iconTip flipped"></span>{$message.warning_message}</li>
                        <xen:if is="{$message.isDeleted}">
                            <li class="deletedNotice"><span class="icon Tooltip" title="{xen:phrase deleted}" data-tipclass="iconTip flipped"></span>{xen:phrase this_message_has_been_removed_from_public_view}</li>
                        <xen:elseif is="{$message.isModerated}" />
                            <li class="moderatedNotice"><span class="icon Tooltip" title="{xen:phrase awaiting_moderation}" data-tipclass="iconTip flipped"></span>{xen:phrase this_message_is_awaiting_moderator_approval_and_is_invisible_to_normal}</li>
                        <xen:if is="{$message.isIgnored}">
                            <li>{xen:phrase you_are_ignoring_content_by_this_member} <a href="javascript:" class="JsOnly DisplayIgnoredContent">{xen:phrase show_ignored_content}</a></li>
        <xen:hook name="message_content" params="{xen:array 'message={$message}'}">
        <div class="messageContent">       
                <blockquote class="messageText SelectQuoteContainer ugc baseHtml{xen:if $message.isIgnored, ' ignored'}">
                    <xen:include template="ad_message_body" />
                    {xen:raw $message.messageHtml}
                    <div class="messageTextEndMarker">&nbsp;</div>
            {xen:raw $messageContentAfterTemplate}
        <xen:if is="{$message.last_edit_date}">
            <div class="editDate">
            <xen:if is="{$message.user_id} == {$message.last_edit_user_id}">
                {xen:phrase last_edited}: <xen:datetime time="{$message.last_edit_date}" />
            <xen:else />
                {xen:phrase last_edited_by_moderator}: <xen:datetime time="{$message.last_edit_date}" />
        <xen:if is="{$visitor.content_show_signature} && {$message.signature}">
            <xen:if hascontent="true">
                <div class="baseHtml signature messageText ugc{xen:if $message.isIgnored, ' ignored'}"><aside><xen:contentcheck>{xen:raw $message.signatureHtml}</xen:contentcheck></aside></div>
        {xen:raw $messageAfterTemplate}
        <div id="likes-{$messageId}"><xen:if is="{$message.likes}"><xen:include template="likes_summary" /></xen:if></div>

    <xen:hook name="message_below" params="{xen:array 'post={$message}','message_id={$messageId}'}" />
    <xen:include template="ad_message_below" />

<xen:if is="{$visitor.content_show_signature} && {$message.signature}">

<xen:if is="{$visitor.user_id} OR (!{$visitor.user_id} AND {xen:helper ismemberof, $message,23})">