MyBB Documentation

Customizing postbit

The 1.6 Documentation is no longer maintained and some information may be outdated.

The MyBB 1.6 series reached end of life on October 1, 2015.

This means there will be no more security or maintenance releases for these series and forums running these versions of MyBB may be at risk of unfixed security issues. All administrators are strongly encouraged to upgrade their forums to the latest release of MyBB as soon as possible.

A postbit

Contents

Introduction

MyBB 1.4.x

The Postbit user information is located in the following templates:

  • postbit - contains the basic layout of the Postbit, and some user information for the horizontal postbit
  • postbit_classic - contains the basic layout of the vertical postbit, and some user information
  • postbit_author_user - contains the user information shown for registered users
  • postbit_author_guest - contains the user information shown for guest postings

To access these templates, go to Admin CP --> Templates & Style --> Templates --> *Expand your set* --> Post Bit Templates

By default, postbit and postbit_classic contain the following information related to the user:

Field Variable
Username & Link {$post['username']} - plain text
{$post['profilelink']} - formatted username with link
Online indicator {$post['onlinestatus']}
User title {$post['usertitle']}
User stars {$post['userstars']}
Group image {$post['groupimage']}
Avatar {$post['useravatar']}
postbit_author_* {$post['user_details']}

The postbit_author_user template, by default, contains the following:

Field Value
Post count {$post['postnum']}
Registration date {$post['userregdate']}
Reputation {$post['replink']}
Warning level {$post['warninglevel']}

May be different depending on individual board modifications and plugins

See the sections on $post and $mybb below to find out what other variables can be used.

MyBB 1.2.x

The Postbit user information is located in templates postbit_author_guest for posts made by guests and deleted users, and postbit_author_user for registered users. You can edit these by going to Admin CP --> Templates --> Modify / Delete --> *expand your template set* --> Postbit Templates --> postbit_author_*

By default, postbit_author_user contains the following information about a user:

Field Variable
Username {$post['username']} - plain text
{$post['profilelink']} - formatted username with link
User title {$post['usertitle']}
Stars {$post['userstars']}
Group image {$post['groupimage']}
Avatar {$post['useravatar']} - HTML
{$post['avatar']} - URL
Post count {$post['postnum']}
Usergroup {$usergroup['title']} - primary usergroup name
Join date {$post['userregdate']}
Online status {$post['onlinestatus']}
Reputation {$post['replink']} - displays entire reputation bit

May be different depending on individual board modifications and plugins

Variable Scope

Any variables in $post, $mybb, and $lang can be used in any of the postbit* templates.

$post

$post contains information about the author of the post, as well as the post itself. See mybb_users and mybb_posts for a listing of possible fields you can display. For example, if you want to show the user's timezone, you would add the following code to the postbit_author_user template:

Timezone: {$post['timezone']}

Custom Profile Fields

Custom profile fields can also be accessed and displayed through {$post}. The format is {$post['fidX']} where X is the ID of the custom profile field. You can find this ID in Admin CP --> Configuration --> Custom Profile Fields (or for MyBB 1.2.x, Admin CP --> Users & Groups --> Custom Profile Fields).

The default custom profile fields can be accessed as follows:

Field Variable
Location {$post['fid1']}
Sex {$post['fid2']}
Bio {$post['fid3']}

Please note that HTML is not escaped by default for custom profile fields! That is, if users enter HTML into the custom profile field, the HTML will be displayed as is, and parsed by the browser. To escape HTML from the custom profile field, please make the following modification to inc/functions_post.php:

Find:

eval("\$post['user_details'] = \"".$templates->get("postbit_author_user")."\";");

Before that line, add:

$post['fidX'] = htmlspecialchars_uni($post['fidX']);

Remember to replace the X with the ID of the custom profile field that you want to display.

$mybb

You can use any $mybb->user variable just like $post, except that the information will be retrieved from the current user's profile. You can also show information from $mybb->settings.

$lang

You can use any loaded language variables in $lang in the postbit.

Edit this page on GitHub