Who's Using a Theme?
#1
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?
Reply
#2
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]
Reply
#3
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.
Reply
#4
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']);
[Image: logo.svg.svg]
Reply
#5
(09-28-2019, 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?
Reply
#6
The function works fine and actively being used in core.
Style selector at footer, in User CP and everywhere.
[Image: logo.svg.svg]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)