# SSO redirect link

**URL:** https://meta.discourse.org/t/sso-redirect-link/84200
**Category:** WordPress
**Created:** [March 30, 2018, 4:30am UTC](https://meta.discourse.org/t/sso-redirect-link/84200 "2018-03-30T04:30:27Z")
**Posts on this page:** 1
**Showing post:** 8

<div class="post-metadata">

### Author: ![angus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/angus/32/341715_2.png) [@angus](https://meta.discourse.org/u/angus)
#### Post date: [February 8, 2021, 11:42am UTC](https://meta.discourse.org/t/sso-redirect-link/84200/8 "2021-02-08T11:42:17Z")

</div>

Hey, we don’t have any current plans to implement anything here beyond the `redirect_to` param.

It’s a little more complicated than it seems to “redirect someone back to the same page they were on”. There are quite a few edge cases. If we added that as a core feature we’d effectively be signing up to support all those edge cases as well 🙂 As you might imagine, there are a lot of different ways to configure a Wordpress site.

I gave you a bit of a [hint on this already](https://meta.discourse.org/t/sso-dynamic-login-and-registration-redirect-url/178106/2), but to help you along a bit more, you or your developer will want to do something like this, namely extend the existing shortcode to automatically set the `route_to` to the current url of the site. You can then figure out the edge cases for that for your own specific site.

In `functions.php`

```plaintext
use WPDiscourse\SSOClient\SSOClientShortcode;

function render_discourse_sso_client_link_with_redirect() {
    $sso = new SSOClientShortcode();
    $protocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http");
    $current_url = "$protocol://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
    $options = array(
      "redirect" => $current_url,
      "login" => "Login"
    );
    return $sso->discourse_sso_client_shortcode( $options );
}
add_shortcode( 'discourse_sso_client_link_with_redirect', 'render_discourse_sso_client_link_with_redirect' );

```

Then in your template use the shortcode `[discourse_sso_client_link_with_redirect]`

---

_[View the full topic](https://meta.discourse.org/t/sso-redirect-link/84200)._
