Add redirect on signup for approved users
Dieser Commit ist enthalten in:
Ursprung
a5a18666ad
Commit
17ba9976c0
1 geänderte Dateien mit 14 neuen und 5 gelöschten Zeilen
19
plugin.rb
19
plugin.rb
|
@ -88,11 +88,10 @@ after_initialize do
|
|||
if Wizard.user_requires_completion?(@user)
|
||||
wizard_id = $redis.get('custom_wizard_redirect')
|
||||
|
||||
unless url === '/'
|
||||
if wizard_id && url != '/'
|
||||
CustomWizard::Wizard.set_redirect(@user, wizard_id, url)
|
||||
url = "/w/#{wizard_id.dasherize}"
|
||||
end
|
||||
|
||||
url = "/w/#{wizard_id.dasherize}"
|
||||
end
|
||||
super(url)
|
||||
end
|
||||
|
@ -116,8 +115,11 @@ after_initialize do
|
|||
@excluded_routes ||= SiteSetting.wizard_redirect_exclude_paths.split('|') + ['/w/']
|
||||
url = request.referer || request.original_url
|
||||
|
||||
if @wizard_id && request.format === 'text/html' && !@excluded_routes.any? { |str| /#{str}/ =~ url }
|
||||
CustomWizard::Wizard.set_redirect(current_user, @wizard_id, request.referer) if request.referer !~ /\/w\//
|
||||
if request.format === 'text/html' && !@excluded_routes.any? { |str| /#{str}/ =~ url } && @wizard_id
|
||||
if request.referer !~ /\/w\// && request.referer !~ /\/invites\//
|
||||
CustomWizard::Wizard.set_redirect(current_user, @wizard_id, request.referer)
|
||||
end
|
||||
|
||||
redirect_to "/w/#{@wizard_id.dasherize}"
|
||||
end
|
||||
end
|
||||
|
@ -144,5 +146,12 @@ after_initialize do
|
|||
end
|
||||
end
|
||||
|
||||
DiscourseEvent.on(:user_approved) do |user|
|
||||
if wizard_id = CustomWizard::Wizard.after_signup
|
||||
user.custom_fields['redirect_to_wizard'] = wizard_id
|
||||
user.save_custom_fields(true)
|
||||
end
|
||||
end
|
||||
|
||||
DiscourseEvent.trigger(:custom_wizard_ready)
|
||||
end
|
||||
|
|
Laden …
In neuem Issue referenzieren