MyBB Community Forums

Full Version: Who's Using a Theme?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I've been brainstorming a way to get the number of users who use each theme in $theme_selector. I checked the admin scripts and found the method for counting this under build_theme_list(), but I am uncertain how to inject it into $theme_selector. Any tips on where I should look?
Run a DB administration tool of your choice, e.g. PHPMyAdmin or adminer.php.

Which theme is used by users? SQL:
SELECT username, style
FROM mybb_users

How many user are using a specific theme? SQL:
SELECT style, COUNT(*)
FROM mybb_users
GROUP BY style

"style" is the ID of the theme.

[ExiTuS]
Thanks for responding.

That's the part that I understood, as I derived from the admin panel. What I'm curious about is how to inject that information into $theme selector. I'm not sure where to hook into for that.
Use MyBB's in-built function build_theme_select() where you can pass the theme id being used by current user as second parameter.

Example:
$theme_selector = build_theme_select("style", $user['style']);
(2019-09-28, 05:13 AM)effone Wrote: [ -> ]Use MyBB's in-built function build_theme_select() where you can pass the theme id being used by current user as second parameter.

Example:
$theme_selector = build_theme_select("style", $user['style']);
Hm, for whatever reason this function always seems to generate a broken theme selector and the $name param doesn't even seem to work. Is this function still supported or am I just dumb?
The function works fine and actively being used in core.
Style selector at footer, in User CP and everywhere.