XF 2.1 BB Code to return value of custom user field

celebrir

Active member
I want to create a BB Code which returns the value of a certain simple custom user field.
I have a staff list as a thread on my internal Forum and I want to include the telephone number of the staff members. (Field ID "user_tel").
I figured I need to use the PHP Callback function on the BBcode, handing over the requested UserID as a parameter.
Could look like this: [GETTEL=1][/GETTEL]

So far I have figured that I get my wanted result with $user.Profile.custom_fields.user_tel but then I got stuck on how to get the $user by ID.
To be quiet honest, I don't know how to proceed either so I'll gladly take the help as detailed as possible 😅


Thanks in advance!
_____
I'm having a hard time trying to wrap my head around the XenForo syntax/Callback methods/Where to start in general.
After reading the /xf2-docs/manual/, Developer Doc and several other threads/resources I came to the conclusion that I need help on where to get started as they do list everything, but lack the sort of explanation I need.

As a side note: I couldn't find a beginner friendly doc/tutorial/etc. on getting started. I'll happily take all the helpful links some of you might have bookmarked.
 
Oops... spot of thread necromancy going on here
I just had to deal with similar issue and searches were pulling up this thread, so thought I'd answer.

There really isn't much documentation about using PHP for callbacks. I can't find any docs about available classes, objects, hooks, etc.
 
Is there any progress on this @Kier ?

In order to display a BBCode in the editor (or not), I would have to implement a callback to find out whether the editor is being opened by a moderator or a normal user.
 
In order to display a BBCode in the editor (or not), I would have to implement a callback to find out whether the editor is being opened by a moderator or a normal user.
Showing the bb-code icon in the editor based on user requires one of two things;
  • A template pre-render hook on public:editor fiddling with the customIcons values.
    • A number of editor options are pre-baked by this stage
  • Extending XF\Template\Templater::formEditor and messing around with \XF::app()->bbCode()->custom to control what bb-codes are available.
    • This is more for advanced extending of the editor.
While there is a removeButtons option in the template arguments, it did not reliably work for versions XF2.2.0 to XF2.2.7 (inclusive)
 
Back
Top Bottom