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

bambini's avatar
Level 11

User Registration via API and the Activate Redirect URL

Hi All, I have an API call, which is used to create a new user with APP_USER role for spark under specific team . I use Team setup and Team billing. I am also using Activate via Email feature.

In my method I am using this simple code to create the user



        $user = new User;
        $user->name = $request->fName;
        $user->last_name = $request->lName;
        $user->email = $request->email;

        $user->password = bcrypt($request->password);
        $user->save();





        $teamUser=new TeamUser;


        $teamUser->team_id=$team_id;

        $teamUser->user_id=$user->id;

        $teamUser->role="app_user";

        $teamUser->save();






        $user->sendEmailVerificationNotification();




But the problem is following. User gets the activation email, clicks on it, and is redirected to

/api/auth/login page. How can I prevent that and set a very specific URL ?

0 likes
1 reply
bobbybouwmann's avatar

If you look into the sendEmailVerificationNotification method you can see that this will send a notification to the user using an email. In the email a route is specified. So what you can do is override the emailtemplate and specifiy a different route. The only think you then need to do is add that route to your application point to the verification controller.

You can find the current route and it's controller by running php artisan route:list

2 likes

Please or to participate in this conversation.