How to Display a User Suspended Message in a XenForo Template

Status

offline

Posts

9

Likes

1

Bits Credits

0

LEVEL

1

210 XP

How do i achieve the below suspension message on my forum

Screenshot_20240422_180307.jpg
 
Liked by:

FateKid

DEVIL DID IT

Admin

Status

offline

Posts

14,962

Likes

131,168

Resources

3,400

Bits Credits

503

LEVEL

11

5,910 XP

This can be done through a simple XenForo if statement in the templates you'd prefer.
For example, if you're looking to add a simple banned message in a template, use something like the code below.

HTML:
// Assumming the $user entity object is available from the template you're editing

<xf:if is="$user.is_banned">
    // ENTER BANNED HTML STRUCTURE HERE
</xf:if>

We had a similar discussion where a member wanted this, you can find that thread here.
 

Status

offline

Posts

9

Likes

1

Bits Credits

0

LEVEL

1

210 XP

Thanks so much FateKid for your swift response, but please can you give me the complete code or example to use in achieving this, the html code to use. Thanks
 

FateKid

DEVIL DID IT

Admin

Status

offline

Posts

14,962

Likes

131,168

Resources

3,400

Bits Credits

503

LEVEL

11

5,910 XP

Thanks so much FateKid for your swift response, but please can you give me the complete code or example to use in achieving this, the html code to use. Thanks
It all depends on what you're looking for. Here's an example, but you'll want to do what's best for your website.

HTML:
<xf:if is="$user.is_banned">
    <div class="nfdev_banned-message--post">
        <p>This member has been suspended. Deal with caution.</p>
    </div>
</xf:if>

COLORS USED -
BACKGROUND COLOR | BORDER COLOR | FOREGROUND COLOR

CSS:
.nfdev_banned-message--post {
    background-color: #8b3f44; /* pastel washed dark red */
    color: #ffffff; /* white text for contrast */
    border: 1px solid #7a2c30; /* slightly darker red for the border */
    padding: 10px;
    border-radius: 6px;
    margin: 10px 0;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    text-align: center;
}
 

FateKid

DEVIL DID IT

Admin

Status

offline

Posts

14,962

Likes

131,168

Resources

3,400

Bits Credits

503

LEVEL

11

5,910 XP

which template should i placed this FateKid
Wherever you'd like to show this banned message ;)
I have no clue what your site is or how it operates. You'll need to make those choices.
 
Liked by:

Aranvdis

Newcomer

Status

offline

Posts

26

Likes

21

Resources

2

Bits Credits

0

LEVEL

1

230 XP

I want to show it on thread view page. thanks
search this post_macros
<xf:macro name="post_user_content" arg-post="!" arg-thread="!" arg-snippet="{{ false }}" arg-displayAds="{{ true }}">"]
add after
<xf:if is="{$post.User.is_banned}">
<div class="message-content js-messageContent">
<div class="blockMessage blockMessage--warning blockMessage--iconic">
This user is banned. <br>Please note, if you want to make a deal or a transaction with this user, do not make it before the end of the ban.
</div></div>
<xf:else />
<div class="message-userContent lbContainer js-lbContainer {{ $post.isIgnored() ? 'is-ignored' : '' }}"
data-lb-id="post-{$post.post_id}"
data-lb-caption-desc="{{ $post.User ? $post.User.username : $post.username }} &middot; {{ date_time($post.post_date) }}">
<xf:if is="$post.isFirstPost()">
<xf:macro template="custom_fields_macros" name="custom_fields_view"
arg-type="threads"
arg-group="before"
arg-onlyInclude="{$thread.Forum.field_cache}"
arg-set="{$thread.custom_fields}"
arg-wrapperClass="message-fields message-fields--before" />
</xf:if>
 

Status

offline

Posts

9

Likes

1

Bits Credits

0

LEVEL

1

210 XP

Thanks so much, please i want to create a user group named suspended and i want to display the same message when I move that user to that group. Can I achieve that with the following code:

Code:
<xf:if is="$xf.visitor.isMemberOf(5)">

    <div class="nfdev_suspended-message--post">

        <p>Member <b>suspended</b> from <b>ForumFrenz</b></p>

    </div>

</xf:if>
 
Liked by:

Aranvdis

Newcomer

Status

offline

Posts

26

Likes

21

Resources

2

Bits Credits

0

LEVEL

1

230 XP

Use my code if someone user is banned and display message from content banned is blocked but others can see others groups :)
better use
<xf:if is="{$post.User.is_banned}">

in post_macros
i tested my code its works. Like on this nullforums function.

create a usergroup like guest aka Unregister and should be ok.
 
Liked by:

Latest threads

Forum statistics

Threads
58,917
Messages
90,093
Members
55,857
Latest member
MojFPS
Top Bottom