How to develop XenForo add-ons?

Luxus

Well-known member
Ok, I decided to learn how to write add-ons for XF. I tried this tutorial successfully: http://xenforo.com/community/threads/creating-an-addon.5416/

The general way to create add-ons is very easy (the ACP stuff), but my question is, where do I get these fancy functions like

public function actionAddThread()
$username = $visitor['username'];
$visitor['message_count']

from?

Is there any documentation with all of XenForo's functions, variables and such? I mean if I want to write an add-on that checks how many likes a user recieved, from where do I get the function besides browsing through all of XenForo's core file and looking for some strings that make sense?

I have experience with MyBB and was able to make my own small mods solely due to a list of available functions and examples. This is something what I miss for XF.
 
  • Like
Reactions: sbj
I mean if I want to write an add-on that checks how many likes a user recieved, from where do I get the function besides browsing through all of XenForo's core file and looking for some strings that make sense?

If you want to check the current logged in user then you can use the visitor object:

Code:
$visitor = XenForo_Visitor::getInstance();
$likes = $visitor['like_count'];

Or use the user model to fetch the user record for a specific user:

Code:
$userModel = XenForo_Model::create('XenForo_Model_User');
$user = $userModel->getUserByName('name here');
$likes = $user['like_count'];
 
If you want to check the current logged in user then you can use the visitor object:

Code:
$visitor = XenForo_Visitor::getInstance();
$likes = $visitor['like_count'];

Or use the user model to fetch the user record for a specific user:

Code:
$userModel = XenForo_Model::create('XenForo_Model_User');
$user = $userModel->getUserByName('name here');
$likes = $user['like_count'];
That's exactly what I mean. From where did you get those variables?
 
That's exactly what I mean. From where did you get those variables?
I think many here are confused as to what exactly it is you are asking since we do not know your level of knowledge.
You will find most action related functions in the library/XenForo/ControllerPublic folder, while most database related functions are located in the library/XenForo/Model folder.
 
Top Bottom