Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

joshuaf's avatar

Spark registration redirect not working

I am trying to redirect a user to a page when they register. I have accomplished this redirect when the user logs in (after initial registration) by altering the following line in the LoginController in vendors/laravel/Spark/src/Http/Controllers/Auth

protected $redirectTo = '/Profile/';

In attempting to do the same thing for the registration, I altered the same line in the RegisterController at the same address. However, that did not work.

I traced the code down to the RedirectsUsers trait which first looks for the redirectPath property and then for the redirectTo property. So it seems like this should work.

However, I get redirected to 'undefined' which would seem to indicate that the 'redirectTo' variable is either protected somewhere that it should not be or is simply missing. The variable is present in the authController for laravel.

Any suggestions on where to look?

0 likes
6 replies
webrgp's avatar

I am running into the same issue: works after login, but not after registration. Any luck on your end?

jpeterson579's avatar

@joshuaf I am still looking for answer to this too. However I think the reason you are getting undefined is because you need to use the route name instead the actual path...?

Cronix's avatar

Spark has a command for that. In the SparkServiceProvider, add this to the booted() method:

Spark::afterLoginRedirectTo('/whereEver');

I believe it should work after registration as well.

jpeterson579's avatar

@Cronix So let me ask you this, lets say a user can register as a business or a person, how would i direct the business to one page and the user to another after registering.

I dont think the Spark::afterLoginRedirectTo('/whereEver'); would accomplish that. Would it?

Cronix's avatar

@jpeterson579 No I don't think it would bc the url is registered during boot, before the user logs in. For what you're wanting, you'd probably have to do it in middleware. I'm using team-slug based urls and that's how I'm doing it, so it redirects to /team-slug/profile, which is of course dynamic.

Please or to participate in this conversation.