Closed git-bhanu closed 2 years ago
I took some time to look into the login for OneTapLogin.php.
It seems that here on (https://github.com/rtCamp/login-with-google/blob/master/src/Modules/OneTapLogin.php#L185-L198)
$decoded_states redirect_to
value is the url which it is getting redirected to.
$redirect_to = apply_filters( 'rtcamp.google_default_redirect', admin_url() );
$state = Helper::filter_input( INPUT_POST, 'state', FILTER_SANITIZE_STRING );
$decoded_state = $state ? (array) ( json_decode( base64_decode( $state ) ) ) : null;
if ( is_array( $decoded_state ) && ! empty( $decoded_state['provider'] ) && 'google' === $decoded_state['provider'] ) {
$redirect_to = $decoded_state['redirect_to'] ?? $redirect_to;
}
wp_send_json_success(
[
'redirect' => $redirect_to,
]
);
die;
How can that be changed to the present page where the oneTap UI is shown ?
need help for same issue. users should stay in same page.
need help for same issue. users should stay in same page.
Hey @bsahins, I made a fork of the plugin to fix this. But its private right now. I don't think its possible without making an edit to the possible.
Hi @bhanu-krenovate, If your version is working it is OK for me :) Can you share the updated file?
@bhanu-krenovate @bsahins You can use rtcamp.google_login_state
filter to set the current URL to maintain the redirect URL in the state. I am sharing the below code as an example, which can help you to achieve this.
function lwg_google_login_state( $args ) {
$request_uri = filter_input( INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_STRING );
$args['redirect_to'] = home_url( $request_uri );
return $args;
}
add_filter( 'rtcamp.google_login_state', 'lwg_google_login_state', 100 );
Let me know how it goes, thanks!
Will try asap. But I suggest to put a small settings about this. So admin can choose where to go. thanks
Solution has already been shared by Vishal, and no changes are required in the plugin for the same.
First of all, great plugin. It works as it is supposed to work out of the box.
I am in need of some custom changes. I am interested in redirecting user to the same page from where he/she actually tried to authenticate himself/herself.
I found the concerned filter.
Right now, I have hardcoded the URL, but I intend to make it dynamic.
The issue being how do I identify what page the user logged in? Is this data passed when logged in? I would be very thankful if you could help me out in setting this up.
Thanks again.