@julian Well thank you for your answer anyway 😊
I'll keep checking this topic in case someone comes up with an idea !
Referrer doesn't redirect?
-
Re: Redirect after register/registration
In my theme I try to accomplish this like so:
library.redirectAfterRegistration = (data, callback) => { user.getUserData(data.uid, (err, userdata) => { if (err) { return callback(err); } const url = nconf.get('relative_path') + '/user/' + encodeURIComponent(userdata.userslug); data.referrer = url; callback(null, data); }); };
Any idea why it's not working? The referrer looks good '/user/[username]'.
-
I am assuming you are using the hook
filter:register.complete
. Did you check if the client side receives the referrer here?If that code isn't getting called maybe GDPR and ToS redirects are interfering.
-
It receives the referrer but only after the first step, not after GDPR and ToS. I'm running version
1.12.1
. -
A related question. If I need to redirect the logged in user to their profile because I need them to fill in a field, how would I go about doing that?
At the moment I catch the hook
filter:middleware.render
and do ares.redirect('/user/[username]/edit')
. It works great on initial render, but when I try to click somewhere the main area just goes blank.I believe it has to do with the api call being made to re-render the page. I am not familiar enough with the inner workings to know why this is happening.
-
The referrer received after the first step is it the value you set in your plugin or is it
/register/complete
?You need to use
helpers.redirect
to properly redirect both regular pages and /api/ requests. -
@magnusvhendin I filed a bug for this, https://github.com/NodeBB/NodeBB/issues/8050
Will need to be fixed in core.
-
@magnusvhendin This is now fixed on latest master, you can replicate the changes here to get the fix.
-
@baris Awesome, thanks a lot!