A couple of development questions coming from vB to Xenforo.


Well-known member
I probably won't start any serious attempts at development for a few weeks as first thing first I am porting our theme over. But reading through some of the tutorials and conversations I have some questions and am mainly looking to be pointed in the right direction so I can learn on my own.

Figure I should give you guys an idea of my level of experience. My background in programming is more windows development as I have been coding in object oriented pascal for 15 years. I have basic skills in PHP and do well as long as no one separates me from my desk references. I am fluent in html and css techniques and have no problem with building my output. But the core concern is of course working with the platform. I wrote some basic stuff for vBulletin like pulling information displaying it in a new profile tab etc. I think that experience will barely provide any help from what I have seen so far.

I have seen this mentioned but do not have an understanding of when a Xenforo DataWriter is used, should be extended or when its safe to write to the database directly. I assume that say a plugin that makes a forum post or changes a usergroup should make use of these DataWriters? We will be doing some things like that such as applications and ban appeals will be posting to the forum as a thread. But most other plugins will be writing to tables specific to the plugin and not an existing part of the forum is that a case when I would just do things like how I did before?

I had a basic understanding of Hooks in vB. But my initial look at "listeners" confuses me a little. Is this basically one in the same? One plugin I have to write for example will basically need to insert something above the first post in a ban appeal thread when being viewed by an administrator. So we basically have a listener for the start of that section and have code that generates what I need output at that point?

Also looking for an example or tutorial on hooking the moderation bar. The application and recruit management plugin as well as the ban appeal system is intended to have notifications in this area. So far I have run across a couple plugins to look at but not such much an existing tutorial?


in memoriam 1991-2020
As for listeners, this resource may be beneficial to you:

It explains when a listener should be used, what its used for (extending a class usually), and how to use it. What is your plugin adding? Is it just some text or do you need to query the database and fetch more information?

Writing a proper XenForo plugin you should use a DataWriter to write to the database, even if its in your own plugin. Code reusability, standards, and fitting the 'mold' would be just 3 reasons. The examples you listed:
  • Writing a forum post: Yes, use a datawriter. Checkout XenForo_ControllerPublic_Thread::actionAddReply() for an example on inserting a post to a thread.
  • Changing user groups: If you are adding / removing a ban, there are various functions to utilize that will do it for you...
    • XenForo_Model_User::liftBan($userId)
    • XenForo_Model_User::ban($userId, $endDate, $reason)
  • Custom applications - not sure on this one, it depends on what you are doing. Are you storing any information or just posting a thread?
  • Writing to your own tables - If you want to fit the XenForo mold, you should use them, but nothing is forcing you to.
As for hooking into the moderation bar, I do not believe there are any tutorials, but it should be a matter of fetching the necessary information and using hooks/template modifications to place it into the system. There is an add-on for "Staff Room Unread Topics" that does this, it might be worth looking into that code to see how to accomplish it.


Well-known member
What is your plugin adding? Is it just some text or do you need to query the database and fetch more information?
  • Custom applications - not sure on this one, it depends on what you are doing. Are you storing any information or just posting a thread?
The website is a gaming community so things like the ban appeals are not for the forums but for the game servers.

With vBulletin the original solution was a plugin that allows us to make forms and these forms just submit a thread. These forms are for things like applying to the clan, ban appeals, and admin complaints. As we grew past 100 members and 10 game servers it became readily apparent we needed a more comprehensive solution to help manage things like recruits or keeping track of a persons previous ban appeals. I felt confident in my ability to write the solutions for bulletin with only minimal additional learning. However we knew our stay on VB would not be forever. Instead of doing this twice we elected to move to Xenforo now and learn to do it here.

The plugin handling applications should be easy a plugin with its own page that when submitted creates a thread. 2 things to learn here one is the simple act of writing a plugin That has its own page and utilizing the proper method of creating a thread programmatically. However this is a simple part of a bigger system. It will make an entry into a table for later use.

The recruit management plugin will mostly be managing data in proprietary tables. However when an applicants trial is done this interface will be used to move them from the registered user group to the trial member group as well as back if needed. As well as moving them to the member group when the trial is over.

Both the ban management plugin and part of the recruit plugin (a voting system) will need to insert something above particular threads. Its pretty routine for plugins think having a top block over a thread as opposed to a side block. These will be mostly to display and provide access to information such as ban history or in the case of the recruit system a spot to cast votes like a poll but not actually a poll. However there is a couple things here I have to learn as these will utilize adjusting a threads prefix and closing threads.

Most of the other proprietary stuff will not be forum related and will just be in xenforo as a plugin to maintain a streamlined environment but thats basic and will be learned almost right away.