Hello Kurt,
Yes, it is possible. I will add this hook just before the redirect.
I will release this in a couple of hours and I will come back with an example on how you can use it.
Hello,
Please update the plugin to version 1.6.3 and you will find the hook simple_jwt_login_redirect_hook.
This hook is called before the user is redirected to the page he specified in the login section.
Example of usage:
add_action(
'simple_jwt_login_redirect_hook',
function($url) {
$redirectUrl = $url . '?something=123'
wp_redirect($redirectUrl);
}
);
PS: $url is the URL where the user is redirected after auto-login.
Best regards.
-
This reply was modified 6 years ago by
Nicu Micle.
Hi,
it works!
Thanks a lot for your fast support.
Best Regards.
Hello Kurt,
Thank you for donating to this plugin.
Have a nice weekend.
Best regards,
Nicu.
Hi @nicu_m , was this tested with the latest WP version? My plugin login setting is set to redirect to homepage, enabling the hook & calling this on functions.php:
add_action(
'simple_jwt_login_redirect_hook',
function($url) {
$redirectUrl = $url . '/page';
wp_redirect($redirectUrl);
}
);
$url therefore should be the homepage, so I should get to homedomain.com/page right? It Seems to just redirect to regular homepage, whatever I put at the $redirectUrl, wether it’s ‘/page’, ‘page’, ‘?something=123’, etc, still just plain homepage. Any idea why?
Ilya
Hello @igurman,
Yes. It is tested with the latest WordPress version.
Please make sure you have enabled the hook from Plugins Settings-> Hooks and save the settings.
In the code, I make a verification if the hook is enabled, and only then the action is triggered.
Also, this function has 2 arguments. Here is a sample how you should call it:
add_action(
'simple_jwt_login_redirect_hook',
function($ur, $requestl) {
$redirectUrl = $url . '?something=123';
wp_redirect($redirectUrl);
}
,10
,2
);
Best regards,
Nicu.
Hi @nicu_m Nicue thanks for the quick reply. Yes that’s how I’m using it and the hook is enabled. Could it be something to do with the install being a multisite? (Even though this is attempted for a single subsite)
I’ve just checked this o the latest WordPress version, in a site from my multisite network.
Try to add this code in wp_config.php or at the bottom of routes.php (wp-content/plugins/simple-jwt-login/routes.php’).
My guess is that the file where you wrote the code, it is not included.
Let me know if this works for you.
Best regards,
Nicu.
@nicu_m appreciate your reply but doesn’t seem to matter where I add it, the hook isn’t called.
I even created my own plugin, and activated on that subsite:
https://ibb.co/gjQnrQR
The hook is enabled:
https://ibb.co/C2mtK5f
It just redirects to whatever is mentioned on the ‘login’ tab of the plugin (homepage, dashboard..) and ignores the hook.
Not sure what I’m doing wrong and sorry for the constant bothering here.
Ilya
-
This reply was modified 5 years, 8 months ago by
igurman.