MyBB Hacks

Full Version: turn username into a profile link
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Whoops! I missed the bit below the code, sorry!
So far the field is ready, it works to choose the accounts, they are displayed everywhere where I wanted them. But they aren't turned into links.
Without custom code modifications, this is really pushing what can be done with XThreads, but I suppose this could be possible, with a bunch of caveats.

You can set the Display Item Format to something like:

HTML Code
<setvar user>get_user_by_username({VALUE})</setvar>
<if $tplvars['user']['uid'] then>
 <?=build_profile_link({VALUE}, $tplvars['user']['uid'])?>
<else>
 {VALUE}
</if>

Caveats:
- get_user_by_username isn't a "safe" function, but if you have the PHP in Templates plugin, it should be allowed.  Alternatively, you can whitelist it by appending it to inc/xthreads/phptpl_allowed_funcs.txt
- it can run a query for every single user specified, which can place more load on the server

In theory, you could also do something similar using the Input Formatter to validate usernames, and store them as user IDs, but you still have the above caveats.

Pages: 1 2
Reference URL's