I’d like a way to restrict themes to particular groups - for example, I’m hoping to give the donators group access to certain exclusive themes and ones that aren’t ready to be released publicly. There any way to do this?
إعجابَين (2)
HAWK
(Hawk)
20 مايو 2018، 9:16م
2
That isn’t currently possible, no.
إعجابَين (2)
John123
(John )
20 مايو 2018، 9:36م
3
That would be a great feature, I wonder if there is a way to develop such a plug-in independently. Also if there were a way to label tags that come from different types of users (or at least differentiate between admin and members. What do you think about that?:grinning
sam
(Sam Saffron)
21 مايو 2018، 12:37ص
4
It could be done in a plugin, it is rather tricky, but doable.
would definitely be useful. got any pointers on how a plugin could work?
david
(David Taylor)
22 مايو 2018، 12:11ص
6
As a starting point, you could have a look at how theme access is overridden for the theme-creator.discourse.org system:
# Override guardian to allow users to preview their own themes using the ?preview_theme_key= variable
add_to_class(:guardian, :allow_theme?) do |theme_key|
return true if Theme.user_theme_keys.include?(theme_key) # Is a 'user selectable theme'
return false if not Theme.theme_keys.include?(theme_key) # Is not a valid theme
# If you own the theme, you are allowed to view it using GET param
# Even staff are not allowed to use GET to access other user's themes, to reduce XSS attack risk
can_hotlink_user_theme? Theme.find_by(key: theme_key)
end
The allow_theme? method is used in Discourse’s application controller here:
def handle_theme
return if request.xhr? || request.format == "json" || request.format == "js"
return if request.method != "GET"
resolve_safe_mode
return if request.env[NO_CUSTOM]
theme_key = request[:preview_theme_key]
user_option = current_user&.user_option
unless theme_key
key, seq = cookies[:theme_key]&.split(",")
if key && seq && seq.to_i == user_option&.theme_key_seq.to_i
theme_key = key
end
end
theme_key ||= user_option&.theme_key
This file has been truncated. show original
As Sam said, what you want to do is possible, but it will require a fair amount of development work to get it working smoothly
10 إعجابات
I kind of did this and tied it to Patreon tiers
I’d like to offer a patreon tier that allows users access to particular themes. Is there any way of showing/hiding themes from particular groups?