• Resolved maphy-psd

    (@maphy-psd)


    Hi,

    I am using the Secure Passkeys login form via shortcode on different frontend pages.

    At the moment, after a successful passkey login, users are always redirected to the homepage. In my use case it would be very helpful if the plugin offered an option to redirect users back to the current page where the shortcode login form was displayed.

    So the desired behavior would be:

    1. User opens a protected or frontend page containing the Secure Passkeys login shortcode.
    2. User logs in with a passkey.
    3. User stays on / is redirected back to that same page.

    Would it be possible to add a plugin setting for this behavior, for example “redirect back to current page after login”?

    Thank you very much for your work on the plugin!

Viewing 1 replies (of 1 total)
  • Plugin Author Mohamed Endisha

    (@endisha)

    @maphy-psd This behavior can already be achieved using the secure_passkeys_login_redirect_url filter.

    For example, the snippet below redirects users back to the page they came from while ignoring the default WordPress login page and the admin area:

    add_filter('secure_passkeys_login_redirect_url', function ($redirect_to) {
    $referer = wp_get_referer();

    if (!$referer) {
    return $redirect_to;
    }

    $path = wp_parse_url($referer, PHP_URL_PATH);

    // Ignore wp-login.php and wp-admin
    if (str_contains($path, 'wp-login.php') || str_starts_with($path, '/wp-admin')) {
    return $redirect_to;
    }

    return wp_validate_redirect($referer, $redirect_to);
    });

    This should work well for shortcode-based login forms on frontend pages.

    If you think it deserves it, a positive rating would be appreciated and would help support the plugin’s continued development.

    Thanks

Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.