# 使用 Discourse SSo 登录后返回 WordPress

**URL:** <https://meta.discourse.org/t/redirecting-back-to-wordpress-after-signing-in-with-discourse-sso/87789>\
**Category:** WordPress\
**Created:** [2018 年5 月 18 日 00:28 UTC](https://meta.discourse.org/t/redirecting-back-to-wordpress-after-signing-in-with-discourse-sso/87789 "2018-05-18T00:28:56Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

作者： ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)\
发布日期： [2018 年5 月 18 日 23:35 UTC](https://meta.discourse.org/t/redirecting-back-to-wordpress-after-signing-in-with-discourse-sso/87789/6 "2018-05-18T23:35:20Z")

</div>

There’s an issue with the Restricted Site Access plugin blocking WordPress REST API requests. If you are publishing posts from WordPress to Discourse, and have enabled the [WP Discourse](https://github.com/discourse/wp-discourse) Sync Comment Data webhook, you will need to modify the conditional statement in first function that I added. (The Sync Comment Data webhook makes the [WP Discourse](https://github.com/discourse/wp-discourse) plugin a lot more efficient on busy sites.)

```plaintext
add_filter( 'restricted_site_access_is_restricted', 'wpdc_custom_restrict_access', 10, 2 );
function wpdc_custom_restrict_access( $is_restricted, $wp ) {
	if ( ( ! empty( $wp->query_vars['discourse_sso'] ) && 1 === intval( $wp->query_vars['discourse_sso'] ) ) ||
	     ! empty( $wp->query_vars['rest_route'] ) ) {

		return false;
	}

	return $is_restricted;
}

```

See this post for details: [https://philipnewcomer.net/2016/05/allow-rest-api-restricted-site-access/](https://philipnewcomer.net/2016/05/allow-rest-api-restricted-site-access/).

---

_[View the full topic](https://meta.discourse.org/t/redirecting-back-to-wordpress-after-signing-in-with-discourse-sso/87789)._
