I think the regex might go something like this…
/ticket/(.*)/?rest_route=/simple-jwt-login/v1/autologin&jwt=JWT
What I am little concerned about, what if the site has many URL paths they want to autologin the user to across campaign?
EX. /certificates/5632
EX. /tickets/1256
EX. /my-account/1236
all on the same site? So you would not want to set 1 redirect URL with wildcard or regex…
Thanks for your help!
Hello Katherine,
Thank you for your review.
You can use the simple_jwt_login_redirect_hook hook in order to redirect to custom pages.
Here is a similar topic that might help you:
https://ww.wp.xz.cn/support/topic/redirect-user-to-based-on-query-after-login/
I’m thinking you can generate login links like ?rest_route=/simple-jwt-login/v1/autologin&jwt=JWT&page=ticket&id=123 and ?rest_route=/simple-jwt-login/v1/autologin&jwt=JWT&page=certificate&id=123, and after that, in you hook you have something like this:
add_action( 'simple_jwt_login_redirect_hook', function($url, $request){
if(isset($request['page']) && isset($request['id']){
$page = $request['page'];
$id = $request['id'];
switch ($page){
case "ticket":
$url = 'https://yousite.com/tickets/' . $id;
break;
case "certificate":
$url = 'https://yoursite.com/support/'. $id;
break;
case "myaccount":
$url = 'https://yoursite.com/myaccount/'. $$id;
break;
}
wp_redirect($url);
exit();
}
}, 10, 2);
Also, if you want to get the details of the registered user, you can make a POST request to /auth/validate and add the JWT. Here is a sample topic: https://ww.wp.xz.cn/support/topic/get-user_id-from-valid-token/
Let me know if you have other questions.
Best regards,
Nicu.