SSO redirect link

I am using wordpress as a SSO client to discourse.

How do I set it up so a user is sent back to the page he/she was on after logging in.

Here is what my SSO URL looks like:

As you can see it redirects to my website homepage. Could I edit this link to redirect the user back to the page he was on? will this mess up the SSO?

Yes, you can set any page on your WordPress site as the value for redirect_to. You probably do not have to URL encode the redirect_to parameter. Something like this should work:

http://theprojectvanlife.com/?discourse_sso=1&redirect_to=http://theprojectvanlife.com/my-wordpress-page

so by adding “my-wordpress-page” as the redirect it will redirect user to the page he/she was on?
Or did you mean to replace “my-wordpress-page” with the page I want the user redirected to?

Yes. set the redirect_to parameter to the URL of the page you want users to end up on.

Is it possible to setup a redirect to link that just sends them back to the same page they were on?

You can use the [discourse_sso_client] shortcode on any WordPress page to create a ‘Login with Discourse’ link that will redirect users back to the page that the shortcode was placed on.

There is some documentation on the plugin’s SSO Client tab for the shortcode.

There was a bug in the most recent versions of the plugin that was causing the shortcode to display the ‘Link your account with Discourse’ text for logged in users who had already linked their account. Update to WP Discourse version 1.6.0 to get the fix.

안녕하세요, 이 기능도 구현해 주시면 플러그인의 기능에 쉽고도 훌륭한 추가가 될 것 같습니다: 독립된 가입 양식/링크?. 저는 Discourse를 SSO 마스터로 사용하고 있으며, 기존 사용자를 위한 로그인 페이지와 신규 사용자를 위한 가입 링크를 함께 제공하고, 사용자가 원래 왔던 페이지로 리디렉션할 수 있다면 매우 유용할 것입니다.

안녕하세요, 현재 redirect_to 파라미터를 넘어 여기에서 더 구현할 계획은 없습니다.

“사용자를 원래 있던 페이지로 다시 리다이렉트하는” 작업은 보이는 것보다 조금 더 복잡합니다. 엣지 케이스가 꽤 많습니다. 이를 핵심 기능으로 추가하게 되면 사실상 해당 엣지 케이스에 대한 지원도 함께 약속하게 되는 셈이죠 :slight_smile: 예상하실 수 있듯이, WordPress 사이트를 구성하는 방법은 매우 다양합니다.

이미 이 문제에 대해 힌트를 드린 적이 있습니다. 조금 더 도움이 되고자 말씀드리면, 귀하나 귀하의 개발자는 기존 쇼트코드를 확장하여 route_to를 사이트의 현재 URL로 자동 설정하는 작업을 수행해야 합니다. 그러면 해당 엣지 케이스를 귀하의 특정 사이트에 맞게 처리할 수 있습니다.

functions.php 파일에서:

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' );

그 후 템플릿에서 쇼트코드 [discourse_sso_client_link_with_redirect]를 사용하시면 됩니다.

고마워, 정말 큰 도움이 됐어, 친구야!